Important Tricks Tips Used in PHP

Important Tricks Tips Used in PHP

PHP, TRENDZ, TUTORIALS

Important Tricks Tips Used in PHP




In this tutorial Important Tricks Tips Used in PHP we are gonna show you some important tricks which are used in PHP. These are the collection of some tips and tricks which are used often in our day to day projects.
Here we list down the tips and tricks every developer must know,
Increase the Script Execution Time
As default in php the maximum execution time is 30 seconds. But in some case we need to increase the execution time when we works in a large projects which takes many mathematical calculations and also some backend process like search a database which has a million of rows.
So here we are in the need to increase the time of execution of the script file. Is there any possible to do it? Yes it is. We can find the option at the file called php.ini. Here we find lot more options not alone this one.
Step 1: Open the php.ini file
We can find the file easily, by open your XAMPP software which is the coordinator for the PHP, Apache, MySQL and FileZila etc. And follow the below procedure.
Another way to open the php.ini file is located at C:\xampp\php.
Important Tricks Tips Used in PHP
In this file find and replace the maximum execution time as much as we want. Here we set it as 120 seconds which means 2 Minutes.
Important Tricks Tips Used in PHP
Step 2: Add the Code in PHP Script File
And save the file, after the above process we have to do one more task is add the below line code at the beginning of our script file whatever it is.




Add Days with Current Date – Important Tricks Tips Used in PHP

And the next trick we have to learn in this tutorial is add additional days to the current date function. It helps to add some particular days in our project for some special occasions. We can do it with simple code like we did it in the below code.

The above code shows, we define a date manually and then add 5 days. Here we use the strtotime() for the data type conversion purpose.

echo “Current Date + Added Date: ” . date(‘Y-m-d’, strtotime(‘ + 10 days’));

The above code is adds 10 days with the current date. Here it takes the current date only, we don’t use any pre-defined date values.
Important Tricks Tips Used in PHP
The above shown result is as per the time of publish this article. You can view the current result at the demo section.
Enable cURL in PHP – Important Tricks Tips Used in PHP
And the next trick we have to know is how to enable the cURL which is an option to supports the URL supported function. Some time we need to enable for the some scripts like the ssl and etc. Here we show how to do that on the various technologies like XAMPP and WAMP.
Enable cURL in XAMPP
Open the xampp\apache\bin\php.ini file.
Uncomment the following line in the php.ini file by removing the semicolon (;).

;extension=php_curl.dll

Restart XAMPP.
Enable cURL in WAMP
Open the WAMP\bin\php\(php version)\php.ini file.
Uncomment the following line in the php.ini file by removing the semicolon (;).

;extension=php_curl.dll

Restart WAMP.
Enable cURL in Ubuntu
Open the etc/(php version)/(apache version)/php.ini file.
Uncomment the following line in the php.ini file by removing the semicolon (;).

;extension=php_curl.dll

Restart the Apache server.




And now we can use our script or software without any issues. These are some basic tips and tricks we can use in our real time projects. We can explore and learn a lot more in the upcoming lessons.

Leave a Reply