I am using CentOS Linux for service purpose. Main reason to use CentOS is cheaper hosting for private purpose. Actually MySQL requires periodical optimization process in my experiences, and I use /etc/cron.hourly usually for those kind of bath processing.&...
I am using Virtual Private Hosting service, and I found that my server has some problem as below. As you can see the CPU occupation rate is more than 300%. So my server response speed is the most slower than I had experiences before. I had read some articl...
There are lots of ways to select a random record or row from a database table. Here are some example SQL statements that don't require additional application logic, but each database server requires different SQL syntax.Select a random row with MySQL: SELE...
The Smarty date_format function returns a formatted string showing date, time and/or seconds.index.php:assign('yesterday', strtotime('-1 day'));$smarty->display('index.tpl');?>index.tpl:{$smarty.now|date_format}{$smarty.n...
Sometimes you need just the filename of the current script, without the path. This snippet does just that using the SCRIPT_NAME and explode function. $currentFile = $_SERVER["SCRIPT_NAME"]; $parts = Explode('/', $currentFile);&n...
for loop - basic control structure. This example loops until the variable hits 10 and then breaks out. 10) { break; } echo $i;}?>sample output :12345678910
There are several ways to process a php form. This example looks for the existance (regardless of value) of the Submit _POST variable.//check if the submit variable existsif ($_POST['Submit']) { echo " got submission ";
Generate a random number using mt_rand. From the php documentation- "If called without the optional min, max arguments mt_rand() returns a pseudo-random value between 0 and RAND_MAX. If you want a random number between 5 and 15 (inclusive), for example, us...
Sometimes you want to be able to give some feedback if a PHP include has failed. Here is a version using the fopen command, which can search the include path.
This example shows a very simple form together with the form handling process on a single page.//check if the submit variable existsif ($_POST['Submit']) { $mytext=$_POST['mytext']; echo " got submission "; ech...
Whatever the formatted string is, strtotime() function convert the formatted date time string to datetime.Following example shows the simple reference can convert date time string whatever the formatted input is...function foo($formatted_time){ retur...
PHP provides the alternate function which can control time limit that defined in php.ini. Following is the alternate function can control time limit.void set_time_limit (int seconds);Set the number of seconds a script is allowed to run. If this is reached,...
The time () function generates a long string of numbers representing how many seconds have passed since January 1, 1970. It is possible to add and subtract time by adding and subtracting seconds.
The three most basic searches using regular expressions are searching for the strings start, the strings end, or for characters it contains. We can do these using the following symbols:^ indicates the string starts with the specified characters, so "^strcp...