<? print “Starting main program\n”; $childs = array(); for ( $count = 1; $count <= 10; $count++) { $pid = pcntl_fork(); if ( $pid == -1 ) { // Fork failed echo “Fork failed\n”; exit(1); } else if ( $pid ) { # parent #print “pid is $pid, parent $$\n”; array_push($childs, $pid); } […]
Debugging PHP – Parse error: syntax error, unexpected $end If you have are using the short form <? for PHP instead of the long form <?php you might be faced with this parse error when running your script on different systems: Update all references to the long version <?php Ensure that all linked files also […]
2002 Cannot log in to the MySQL server – MAC To fix In /etc/php.ini, replaced the three occurences of /var/mysql/mysql.sock with /tmp/mysql.sock prompt% sudo chmod u+w php.ini <- had to give myself write permission to that file.. you may need to become root user to actually edit the file.. depends who owns php.ini Now edit […]
Open_basedir issues Check /var/www/php-fcgi-scripts/web4/.php-fcgi-starter
PHP Deprecated: Comments starting with ‘#’ are deprecated in /etc/php5/cli/conf.d/imagick.ini on line 1 in Unknown on line 0 Just change the ‘#’ in the files to ‘;’ and this error will stop!
The PHP date() function is used to format a time and/or date. The PHP Date() Function The PHP date() function formats a timestamp to a more readable date and time. A timestamp is a sequence of characters, denoting the date and/or time at which a certain event occurred. Syntax date(format,timestamp) Parameter Description format Required. Specifies […]
PHP Array An array stores multiple values in one single variable. What is an Array? A variable is a storage area holding a number or text. The problem is, a variable will hold only one value. An array is a special variable, which can store multiple values in one single variable. If you have a […]
GET or POST – Secure GET is NOT Secure GET is not a secure method of sending data. Don’t use it for forms that send password info, credit card data or other sensitive information. Since the data is passed through as part of the URL, it’ll show up in the web server’s logfile (complete with […]
Given a size in KB, try to return a more readable MB, GB or TB answer string function readable_size_for_kb($mykb) { if ( $mykb > 1073741824 ) { return sprintf(“%5.1f TB”,$mykb / 1024 / 1024/1024); } elseif ( $mykb > 1048576 ) { return sprintf(“%5.1f GB”,$mykb / 1024 / 1024); } elseif ( $mykb > 1024 […]
Readable Time – PHP, given a UNIX timestamp, return a readable time # Given a unix timestamp, returns in readable time ie “1 day, 7 hours, 23 minutes, 2 seconds” function readable_time($timestamp, $num_times = 2) { //this returns human readable time when it was uploaded (array in seconds) $times = array(31536000 => ‘year’, 2592000 => […]