I am a self thought PHP coder and when I was new to this fantastic language I always wanted to know why errors are errors and why certain functions are causing errors. Also I was clueless of why errors are (sometimes) hyplerlinked?
Likewise, every PHP newbie would ask the same frustrating question and would want a description of the mystery behind the error.
Here, I will show you a quick tip to turn your test environment into a study center. Follow the steps below and enjoy your time with PHP.
Hint: I assume you are using XAMPP (the all-in-one suite of Apache, mySQL and PHP) running on Windows machine. You can still implement this technique in any PHP installation though.
Visit the PHP manual download page, and select one of the downloads under the ‘Many HTML files’ column. There are many languages to choose from but the English version is the most accurate.
Extract the downloaded archive. Inside the extracted archive you should find a folder named ‘html’. Copy that folder —and its contents— into the following directory:
After successfully copying the folder into the XAMPP installation directory, rename your copied folder to ‘phpmanual’. It should be something like this:
Well, we placed the PHP manual above the
DocumentRoot, just in an out-of-web-reach directory, the reason is that there may be multiple domains or hostnames maintained on the machine via VirtualHost containers, so we need to make the manual work on every domain or hostname on the machine.
Open the XAMPP configuration file:
…then insert these lines in it:
Alias /phpmanual "C:/<your-xampp-installation-path>/phpmanual/" <Directory "C:/<your-xampp-installation-path>/phpmanual"> AllowOverride AuthConfig Order allow,deny Allow from all </Directory>
Just make sure to change
C:/<your-xampp-installation-path> to your XAMPP installation drive and path, respectively.
Next, open your PHP.INI file found at:
C:\<your-xampp-installation-path>\PHP\php.ini and find the following line:
;html_errors = Off
Uncomment the above directive, then turn it on like this:
html_errors = On
Find these two lines:
;docref_root = "/phpmanual/" ;docref_ext = .html
Uncomment the above two directives, they should match the code below:
docref_root = "/phpmanual/" docref_ext = .html
Save your changes and close the file.
Now, lets see if our effort is working properly. Create a PHP file with the following code inside it:
<?php include 'a-php-file-that-does-not-exist.php'; ?>
Save the file as
C:\<your-xampp-installation-path>\htdocs\, then visit the following URL in your browser:
If everything was correct, you should receive an error like the following one:
Warning: include(a-php-file-that-does-not-exist.php) [function.include.html]: failed to open stream: No such file or directory in C:\web-server\htdocs\localhost\test-manual.php on line 3 Warning: include() [function.include.html]: Failed opening 'a-php-file-that-does-not-exist.php' for inclusion (include_path='.;C:\web-server\php\pear\') in C:\web-server\htdocs\localhost\test-manual.php on line 3
function.include.html should be hyperlinked and when you click it you should see a page describing the error, otherwise, there is something wrong with your configuration.
Never use this feature for production boxes. This feature was intended to support your development since it makes it easy to look-up an error or function description. However it should never be used on live websites (e.g. systems connected to the Internet).