In this tutorial learn PHP this time we will learn how to change/edit a file through PHP configuration file php.ini. This sounds a bit complicated. But by knowing how to change PHP settings, will help us in mastering PHP.
Looking for PHP.ini file with phpinfo()
Just like MySQL, Entire PHP settings in a configuration file called PHP.ini. Depending on the default PHP.ini file could be in the Windows system folder, or in a folder of PHP itself.
To know the location of the PHP.ini file, run the XAMPP and Apache web server, and then from the localhost home page, find the menu of phpinfo() in the left menu.
phpinfo() is a default PHP function is used to find out the settings of PHP itself. You can also display phpinfo by creating a PHP file, and write the following code :
In the display phpinfo() will be visible throughout the PHP configuration. However, you cannot change the configuration on this page, but had to change it directly on the file php.ini.
Top of page note the phpinfo(), you will find the value of “Loaded Configuration File“, this is the address of the location of the PHP.ini that we seek. In my example, the file is located at D:\xampp\php\php.ini, please open Windows Explorer and search for this file.
Get to know the PHP Configuration File : php.ini
The PHP.ini file is a text file that we can open it with the application text always, like the default Windows Notepad, but if you have already installed the application Notepad ++, open with Notepad + +, because Notepad ++ features syntax highlighting, which distinguishes between settings and comments, so that simplify the process of editing the php.ini settings.
The php.ini file has certain rules, i.e. the whole of the line beginning with a semicolon (the semicolon) “;” is considered as a comment and will not be executed by PHP. If you notice, 80% content of php.ini is a comment, so we can easily understand what for those settings.
Most of the default php.ini requires only a single line and gave him the value of on, off or a specific value. Almost every default php.ini is preceded by an explanation of the purpose and the goal.
For example, the tutorial on how to insert PHP code into HTML, we need to modify the PHP.ini settings so that PHP can support SMGL method Style and ASP Style.
HP ASP Style tags method, so it can not be used.
To make the order for the PHP support SMGL Style, the settings must be changed is the short_open_tag. This serves to make default PHP support tags “<?” and “?>“.
Look for the word short_open_tag in php.ini, use the search facilities of Notepad ++. In php.ini there may be more than 1 Word, search for short_open_tag short_open_tag = off, and change its value being On.
As for the default ASP Style, which needs to be changed is the default asp_tags =on.
Once again, save the modified php.ini. In order for the settings we just change can be active, we should restart the Apache Web Server. Open the XAMPP Control Panel, Click the Stop button on the Action of the Apache, and then click the Start button again.
To test it, create a new php file, we just call the opentag.php, type the following code:
echo "This comes from an Open Tag";
echo "This comes from the ASP Style";
Save and run in the browser.
If you find the result in the browser there is a sign “<?” and “<%“, then default PHP yet support SGML and ASP Style as the way we go into the PHP mode. However, if the web browser display like the look above, means the default php.ini has been successfully changed.
To change the default PHP other measures used are the same as above, but for a more secure, copylah php.ini file in the backup folder to the default settings, so if you dabble in PHP settings and found there is a problem, you live cut early php.ini.
later in the Tutorial Learn PHP in webspoint we will go directly into the PHP programming. We will learn about the basic rules of writing PHP code.