<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux, Programming, Telephony, Asterisk, Apache, Tips &#38; Tricks &#187; PHP</title>
	<atom:link href="http://shahidz.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://shahidz.com</link>
	<description>Passionate About Technology</description>
	<lastBuildDate>Sun, 10 Jan 2010 17:38:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>URL Redirecting (301,302) in Varnish</title>
		<link>http://shahidz.com/url-redirecting-301302-in-varnish/</link>
		<comments>http://shahidz.com/url-redirecting-301302-in-varnish/#comments</comments>
		<pubDate>Wed, 22 Oct 2008 17:37:04 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[301]]></category>
		<category><![CDATA[302]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[url redirection]]></category>
		<category><![CDATA[varnish]]></category>
		<category><![CDATA[vcl]]></category>

		<guid isPermaLink="false">http://shahidz.com/url-redirecting-301302-in-varnish/</guid>
		<description><![CDATA[There is no straight forward method for 301/302 URL redirection as we did with rewrite rule. But there are some situations where we need to redirect a URL on a host to some URL on different host. In this situation we need to use 301/302 redirection.  There are two ways we can implement this.
First method [...]]]></description>
			<content:encoded><![CDATA[<p align="justify">There is no straight forward method for 301/302 URL redirection as we did with <a href="http://shahidz.com/apache-url-rewriting/" title="Rewrite Rule" target="_blank">rewrite rule</a>. But there are some situations where we need to redirect a URL on a host to some URL on different host. In this situation we need to use 301/302 redirection.  There are two ways we can implement this.</p>
<p align="justify">First method is to use  <em>set req.http.host</em> and <em>set req.url</em> in the vcl.conf file. Using these two methods we perform normal redirection. Using these method we will redirect the url to some other URL on the same host. For example say the URL http://example.com/error500.php will be redirect to the URL http://example.com/redirect.php. We specify 301/302 redirection to the URL http://foo.com/index.php in the redirect.php file using header method.</p>
<ul>
<li>In the sub vcl_recv method use the following code.</li>
</ul>
<pre>sub vcl_recv {
   if (req.http.host ~ "example.com") {
      if (req.url ~ "error500.php") {
         set req.http.host = "example.com";
         set req.url = "/redirect.php";
      }
   }
}</pre>
<ul>
<li>In the redirect.php file use the following method.</li>
</ul>
<pre>&lt;?php
header("HTTP/1.1 302 Moved Temperarly");
header('Location:http://foo.com/index.php');
exit;
?&gt;</pre>
<p>Second method is to use <em>vcl_error</em> error method. In this error method we can specify HTML tags, so using meta tags we can implement redirection. This option is available with the latest version of varnish.</p>
<ul>
<li>In the sub vcl_recv method use the following code.</li>
</ul>
<pre>sub vcl_recv {
   if (req.http.host ~ "example.com") {
      if (req.url ~ "error500.php")
         error;
      }
   }
}
sub vcl_error {
        set obj.http.Content-Type = "text/html; charset=utf-8";
        if (req.http.host ~ "example.com") {
                if (req.url ~ "error500.php") {
                        synthetic {"
                                &lt;?xml version="1.0" encoding="utf-8"?&gt;
                                &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
                                &lt;html&gt;
                                        &lt;head&gt;
                                                &lt;meta http-equiv="refresh" content="0;url=http://foo.com/index.php"&gt;
                                        &lt;/head&gt;
                                &lt;/html&gt;
                        "};
                }
        }
        deliver;
}</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Furl-redirecting-301302-in-varnish%2F&amp;linkname=URL%20Redirecting%20%28301%2C302%29%20in%20Varnish"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/url-redirecting-301302-in-varnish/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Log or mail Errors in PHP Code</title>
		<link>http://shahidz.com/how-to-log-or-mail-errors-in-php-code/</link>
		<comments>http://shahidz.com/how-to-log-or-mail-errors-in-php-code/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 17:21:26 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[handling]]></category>

		<guid isPermaLink="false">http://shahidz.com/how-to-log-or-mail-errors-in-php-code/</guid>
		<description><![CDATA[There are a number of things that can go wrong in code and they bound to through errors, even if you&#8217;ve tested them hundreds of times. PHP provides some error handling methods such as error_reporting(), set_error_handler(), error_log(), restore_error_handler() for handling errors in the PHP code.
error_reporting &#8211; Sets which PHP errors are reported.
int error_reporting ([ int [...]]]></description>
			<content:encoded><![CDATA[<p>There are a number of things that can go wrong in code and they bound to through errors, even if you&#8217;ve tested them hundreds of times. PHP provides some <a href="http://in2.php.net/manual/en/ref.errorfunc.php">error handling</a> methods such as <em>error_reporting()</em>, <em>set_error_handler()</em>, <em>error_log(), restore_error_handler() </em>for handling errors in the PHP code.</p>
<p class="refpurpose"><a href="http://in2.php.net/manual/en/function.error-reporting.php"><strong><span class="refname">error_reporting</span></strong></a> &#8211; <span class="dc-title">Sets which PHP errors are reported.</span></p>
<pre class="refpurpose"><span class="type">int</span> <span class="methodname"><strong><strong>error_reporting</strong></strong></span> ([ <span class="methodparam"><span class="type">int</span> <tt class="parameter">$level</tt></span>] )</pre>
<p><a href="http://in2.php.net/manual/en/errorfunc.constants.php" target="_blank">error_reporting() level constants</a></p>
<pre>&lt;?php error_reportinng(E_ALL);?&gt;</pre>
<p class="refpurpose"><a href="http://" target="_blank"><strong><span class="refname">error_log</span></strong></a> &#8211; Sends an error message to the web server&#8217;s error log, a    <acronym title="Transmission Control Protocol">TCP</acronym> port or to a file.</p>
<pre class="refpurpose"><span class="type">bool</span> <span class="methodname"><strong><strong>error_log</strong></strong></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$message</tt></span>  [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$message_type</tt></span>  [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$destination</tt></span>  [, <span class="methodparam"><span class="type">string</span> <tt class="parameter">$extra_headers</tt></span> ]]] )</pre>
<p class="refpurpose"><strong>Parameters</strong></p>
<p class="refpurpose">$message &#8211; The error message that should be logged.</p>
<p class="refpurpose">$message_type &#8211; Says where the error should go. The possible message types are as         follows:</p>
<p class="refpurpose">$extra_headers &#8211; The extra headers. It&#8217;s used when the <em><tt class="parameter">message_type</tt></em>         parameter is set to <em>1</em>.        This message type uses the same internal function as         <a href="http://in2.php.net/manual/en/function.mail.php" target="_blank" class="function">mail()</a> does.</p>
<p class="refpurpose"><a href="http://in2.php.net/manual/en/function.restore-error-handler.php" target="_blank"><strong><span class="refname">restore_error_handler</span></strong></a> &#8211; <span class="dc-title">Restores the previous error handler function</span></p>
<pre class="refpurpose"><span class="type">bool</span> <span class="methodname"><strong><strong>restore_error_handler</strong></strong></span> ( <span class="methodparam">void</span> )</pre>
<pre>&lt;?phprestore_error_handler();?&gt;</pre>
<p class="refpurpose"><a href="http://in2.php.net/manual/en/function.set-error-handler.php"><span class="refname">set_error_handler</span></a> &#8211; <span class="dc-title">Sets a user-defined error handler function</span></p>
<pre ><a href="http://" target="_blank"><span class="type"></span></a><a class="type mixed">mixed</a> <span class="methodname"><strong><strong>set_error_handler</strong></strong></span> ( <span class="methodparam"><a href="http://" target="_blank"><span class="type"></span></a><a class="type callback">callback</a></span> <tt class="parameter">$error_handler</tt>  [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$error_types</tt></span>] )</pre>
<p>Example:</p>
<pre> &lt;?php 
error_reporting(E_ALL); 
function on_error($num, $str, $file, $line) {
    print "Encountered error $num in $file, line $line: $str\n"; 
    error_log("Error: Encountered error $num in $file, line $line: $st",1,  "dev@gmail.com","From: sys@gmail.com"); 
} 
set_error_handler("on_error"); 
restore_error_handler();?&gt;</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Fhow-to-log-or-mail-errors-in-php-code%2F&amp;linkname=How%20to%20Log%20or%20mail%20Errors%20in%20PHP%20Code"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/how-to-log-or-mail-errors-in-php-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Symfony Framework in Ubuntu</title>
		<link>http://shahidz.com/installing-symfony-framework-in-ubuntu/</link>
		<comments>http://shahidz.com/installing-symfony-framework-in-ubuntu/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 16:24:27 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://shahidz.com/installing-symfony-framework-in-ubuntu/</guid>
		<description><![CDATA[Install these packages with apt:
php5
php5-cli
php5-dev
php5-sqlite
php-pear
$ sudo apt-get install php5 php5-cli php5-dev php5-sqlite php-pear
Test if Apache and PHP are up and running typing in the browser:
http://localhost/
You should see something like:
Apache/2.0.55 (Ubuntu) PHP/5.1.2-1ubuntu1 Server at localhost Port 80
From the command line, as root:
$ sudo pear upgrade PEAR
$ sudo pear channel-discover pear.symfony-project.com
Edit /etc/php5/cli/php.ini and change the line:
memory_limit = [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Install these packages with apt:</strong></p>
<p>php5<br />
php5-cli<br />
php5-dev<br />
php5-sqlite<br />
php-pear</p>
<pre>$ sudo apt-get install php5 php5-cli php5-dev php5-sqlite php-pear</pre>
<p>Test if Apache and PHP are up and running typing in the browser:</p>
<p>http://localhost/</p>
<p>You should see something like:</p>
<p>Apache/2.0.55 (Ubuntu) PHP/5.1.2-1ubuntu1 Server at localhost Port 80</p>
<p><strong>From the command line, as root:</strong></p>
<pre>$ sudo pear upgrade PEAR
$ sudo pear channel-discover pear.symfony-project.com</pre>
<p>Edit /etc/php5/cli/php.ini and change the line:</p>
<p>memory_limit = 8M To memory_limit = 16M</p>
<p>Then</p>
<pre>$ sudo pear install symfony/symfony
$ sudo pear install –alldeps http://phing.info/pear/phing-current.tgz</pre>
<style type="text/css">- 		@page { size: 21cm 29.7cm; margin: 2cm } 		P { margin-bottom: 0.21cm } 	--> 	</style>
<p>Using the command:</p>
<pre>$ sudo pear config-show</pre>
<p>we find the symfony libraries have been installed in:</p>
<pre>$ php_dir/symfony/ /usr/share/php/symfony/ main libraries
$ data_dir/symfony/ /usr/share/php/data/symfony/ skeleton of symfony applications, default modules and configuration
$ doc_dir/symfony/ /usr/share/php/docs/symfony/ documentation</pre>
<p>From the command line enter bellow command:</p>
<pre>$ symfony -Vsymfony version 0.6.2</pre>
<p>From the command line, as root:</p>
<pre>$ mkdir /var/www/myproject
$cd /var/www/myproject
$ symfony init-project myproject
$ symfony init-app myapp</pre>
<p>Edit /Virtual Host configuration file , and append the following at the end:</p>
<pre>&lt;VirtualHost 192.168.1.2:81&gt;
ServerAdmin webmaster@localhost
ServerName servername.com
ServerAlias www.servername.com
DocumentRoot /var/www/project/web
Alias /sf /usr/share/php/data/symfony/web/sf
&lt;Directory /var/www/project/web&gt;
     Options FollowSymLinks MultiViews
     AllowOverride all
     Order allow,deny
     allow from all
&lt;/Directory&gt;
&lt;/VirtualHost&gt;</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Finstalling-symfony-framework-in-ubuntu%2F&amp;linkname=Installing%20Symfony%20Framework%20in%20Ubuntu"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/installing-symfony-framework-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to setup Memcached server</title>
		<link>http://shahidz.com/how-to-setup-memcached-server/</link>
		<comments>http://shahidz.com/how-to-setup-memcached-server/#comments</comments>
		<pubDate>Sun, 01 Jun 2008 10:04:12 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mysql]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://shahidz.com/?p=27</guid>
		<description><![CDATA[Introduction
Memcached is a high-performance, distributed caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in memory to reduce the number of times the database must be read.
Installing memcached
shahid@shahid-laptop:~$ sudo apt-get install memcached
shahid@shahid-laptop:~$ sudo apt-get install php5-memcache
After installing these two packages next step is to configure memcached.conf file. [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>Memcached is a high-performance, distributed caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in <span class="mw-redirect">memory</span> to reduce the number of times the database must be read.</p>
<p><strong>Installing memcached</strong></p>
<pre>shahid@shahid-laptop:~$ sudo apt-get install memcached
shahid@shahid-laptop:~$ sudo apt-get install php5-memcache</pre>
<p>After installing these two packages next step is to configure memcached.conf file. ( /etc/memcached.conf )<a href="http://shahidz.com/wp-content/uploads/2008/06/memcached.txt" title="Memcached.conf">Memcached.conf</a></p>
<p>After that edit the memecached.ini file. ( /etc/php5/apache2/conf.d/memcache.ini )</p>
<p>A sample memcache.ini file</p>
<pre>; uncomment the next line to enable the module
extension=memcache.so
[memcache]
memcache.dbpath="/var/lib/memcache"
memcache.maxreclevel=0
memcache.maxfiles=0
memcache.archivememlim=0
memcache.maxfilesize=0
memcache.maxratio=0
session.save_handler = memcache
session.save_path = "tcp://192.168.1.1:11211?weight=1,tcp://192.168.1.2:11211"</pre>
<p>There are some situations where you want to store instances of memcache on two servers. On this situaltion you want to set &#8217;session.save_path&#8217; as in the above example as comma separated.After that start memcached</p>
<pre>shahid@shahid-laptop:~$ memcached -d   ==&gt; Start memcache as a background process</pre>
<pre>shahid@shahid-laptop:~$ memcached -vv ==&gt; Start memcached as a foreground process</pre>
<p>For testing memcached you can start memcached using -vv option . If you start memcached using -vv option you can see stroing session on memcache on the terminal.</p>
<pre>shahid@shahid-laptop:~$ memcached -vv
slab class   1: chunk size     96 perslab 10922
slab class   2: chunk size    120 perslab  8738
slab class   3: chunk size    152 perslab  6898
slab class   4: chunk size    192 perslab  5461
slab class   5: chunk size    240 perslab  4369
slab class   6: chunk size    304 perslab  3449
slab class   7: chunk size    384 perslab  2730
slab class   8: chunk size    480 perslab  2184
slab class   9: chunk size    600 perslab  1747
slab class  10: chunk size    752 perslab  1394
slab class  11: chunk size    944 perslab  1110
slab class  12: chunk size   1184 perslab   885
slab class  13: chunk size   1480 perslab   708
slab class  14: chunk size   1856 perslab   564
slab class  15: chunk size   2320 perslab   451
slab class  16: chunk size   2904 perslab   361
slab class  17: chunk size   3632 perslab   288
slab class  18: chunk size   4544 perslab   230
slab class  19: chunk size   5680 perslab   184
slab class  20: chunk size   7104 perslab   147
slab class  21: chunk size   8880 perslab   118
slab class  22: chunk size  11104 perslab    94
slab class  23: chunk size  13880 perslab    75
slab class  24: chunk size  17352 perslab    60
slab class  25: chunk size  21696 perslab    48
slab class  26: chunk size  27120 perslab    38
slab class  27: chunk size  33904 perslab    30
slab class  28: chunk size  42384 perslab    24
slab class  29: chunk size  52984 perslab    19
slab class  30: chunk size  66232 perslab    15
slab class  31: chunk size  82792 perslab    12
slab class  32: chunk size 103496 perslab    10
slab class  33: chunk size 129376 perslab     8
slab class  34: chunk size 161720 perslab     6
slab class  35: chunk size 202152 perslab     5
slab class  36: chunk size 252696 perslab     4
slab class  37: chunk size 315872 perslab     3
slab class  38: chunk size 394840 perslab     2
slab class  39: chunk size 493552 perslab     2
&lt;3 server listening
&lt;7 new client connection
&lt;7 get 190c562b24186ff47914309b3ceaab95
&gt;7 END
&lt;7 set 190c562b24186ff47914309b3ceaab95 0 1440 0
&gt;7 STORED
&lt;7 connection closed.
&lt;7 new client connection
&lt;7 get 8c1f38e6f02939cea6a6563049e216c8
&gt;7 END
&lt;8 new client connection
&lt;8 get 7925615c1ab9933cb33af0121881a82b
&gt;8 END</pre>
<p>Another method for checking whether memcached was enamble or not is to check the phpinfo() function. In the phpinfo page should contain memcache module.</p>
<p><a href="http://shahidz.com/wp-content/uploads/2008/06/screenshot.png" title="Memcache module"><img src="http://shahidz.com/wp-content/uploads/2008/06/screenshot.png" alt="Memcache module" /></a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Fhow-to-setup-memcached-server%2F&amp;linkname=How%20to%20setup%20Memcached%20server"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/how-to-setup-memcached-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Background Process or a Deamon Process using PHP</title>
		<link>http://shahidz.com/background-process-or-a-deamon-process-using-php/</link>
		<comments>http://shahidz.com/background-process-or-a-deamon-process-using-php/#comments</comments>
		<pubDate>Mon, 17 Mar 2008 06:33:18 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[background process]]></category>
		<category><![CDATA[deamon]]></category>
		<category><![CDATA[pcntl]]></category>

		<guid isPermaLink="false">http://shahidz.com/?p=16</guid>
		<description><![CDATA[ Process Control Functions (PCNTL) 
 Introduction 
Process Control support in PHP implements the Unix style of process creation, program execution, signal handling and process termination. Process Control should not be enabled within a web server environment and unexpected results may happen if any Process Control functions are used within a web server environment.
 Requirements [...]]]></description>
			<content:encoded><![CDATA[<p class="entry"><strong><u> Process Control Functions (PCNTL) </u></strong></p>
<p><em><u> Introduction </u></em></p>
<p>Process Control support in PHP implements the Unix style of process creation, program execution, signal handling and process termination. Process Control should not be enabled within a web server environment and unexpected results may happen if any Process Control functions are used within a web server environment.</p>
<p><em><u> Requirements </u></em></p>
<p>No external libraries are needed to build this extension.</p>
<p><em><u> Installation </u></em></p>
<p>Process Control support in PHP is not enabled by default. You have to compile the CGI or CLI version of PHP with –enable-pcntl configuration option when compiling PHP to enable Process Control support.</p>
<p><strong> Examples </strong></p>
<p>This example forks off a daemon process with a signal handler.</p>
<p>#!/usr/local/bin/php -q //Include the file php</p>
<p>&lt;&#8217;?php&#8217;<br />
declare(ticks=1);<br />
$cmd = ‘php’;<br />
$file = array(’parse.php’);<br />
$pid = pcntl_fork();<br />
if ($pid == -1)<br />
{<br />
die(”could not fork”);<br />
}<br />
else if ($pid)<br />
{<br />
echo “parent”;<br />
exit(); // we are the parent<br />
}<br />
else<br />
{<br />
echo “Child”;<br />
exit(); // we are the child<br />
}<br />
// detatch from the controlling terminal<br />
if (posix_setsid() == -1)<br />
{<br />
echo $pid;<br />
echo “\n”;<br />
die(”could not detach from terminal\n”);<br />
}</p>
<p>// setup signal handlers<br />
pcntl_signal(SIGTERM, “sig_handler”);<br />
pcntl_signal(SIGHUP, “sig_handler”);</p>
<p>// loop forever performing tasks<br />
while (1)<br />
{<br />
// do something interesting here<br />
pcntl_exec(’php’,&#8217;file.php’); // executes ‘file.php’ in the back ground.<br />
echo “”;<br />
//              exit;</p>
<p>}<br />
function sig_handler($signo)<br />
{</p>
<p>switch ($signo)<br />
{<br />
case SIGTERM:<br />
// handle shutdown tasks<br />
echo “\nShutdown”;<br />
exit;<br />
break;<br />
case SIGHUP:<br />
// handle restart tasks<br />
echo “restart”;<br />
break;<br />
default:<br />
// handle all other signals<br />
}</p>
<p>}</p>
<p>‘?&gt;’</p>
<p>For more details <a href="http://www.php.net/manual/en/ref.pcntl.php"> Click here </a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Fbackground-process-or-a-deamon-process-using-php%2F&amp;linkname=Background%20Process%20or%20a%20Deamon%20Process%20using%20PHP"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/background-process-or-a-deamon-process-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Maps API</title>
		<link>http://shahidz.com/google-maps-api/</link>
		<comments>http://shahidz.com/google-maps-api/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 12:38:08 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[Micellanious]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[google map API]]></category>
		<category><![CDATA[Google Map Key]]></category>

		<guid isPermaLink="false">http://shahidz.com/?p=7</guid>
		<description><![CDATA[What is the Google Maps API?
The Google Maps API lets you embed Google Maps in your own web pages with JavaScript. The API provides a number of utilities for manipulating maps (just like on the  shahidz.com/map.php  web page) and adding content to the map through a variety of services, allowing you to create [...]]]></description>
			<content:encoded><![CDATA[<p><strong>What is the Google Maps API?</strong></p>
<p>The Google Maps API lets you embed Google Maps in your own web pages with JavaScript. The API provides a number of utilities for manipulating maps (just like on the <a href="http://shahidz.com/map.php"> shahidz.com/map.php </a> web page) and adding content to the map through a variety of services, allowing you to create robust maps applications on your website.</p>
<p>For enabling Google Map in your site you need a key. You can generate the key from this link : <a href="http://code.google.com/apis/maps/signup.html">http://code.google.com/apis/maps/signup.html</a></p>
<p><a href="http://shahidz.com/map.php" target="_blank" title="Google Map API"><img src="http://shahidz.com/wp-content/uploads/2008/02/screenshot-1.png" alt="Google Map API" /></a></p>
<p><strong>Example program for a simple Google Map showing Cochin</strong><br />
&lt;!DOCTYPE html PUBLIC &#8220;-//W3C//DTD XHTML 1.0 Strict//EN&#8221;<br />
&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&#8221;&gt;<br />
&lt;html xmlns=&#8221;http://www.w3.org/1999/xhtml&#8221;&gt;<br />
&lt;head&gt;<br />
&lt;meta http-equiv=&#8221;content-type&#8221; content=&#8221;text/html; charset=utf-8&#8243;/&gt;<br />
&lt;title&gt;Google Maps JavaScript API Example&lt;/title&gt;<br />
&lt;script src=&#8221;http://maps.google.com/maps?file=api&amp;v=2&amp;key=GIVE YOUR GOOGLE MAP API KEY HERE&#8221;<br />
type=&#8221;text/javascript&#8221;&gt;&lt;/script&gt;<br />
&lt;script type=&#8221;text/javascript&#8221;&gt;</p>
<p>//&lt;![CDATA[</p>
<p>function load() {<br />
if (GBrowserIsCompatible()) {<br />
var map = new GMap2(document.getElementById("map"));<br />
//        map.setCenter(new GLatLng(37.4419, -122.1419), 13);<br />
//        map.setCenter(new GLatLng(8.81355,77.335328), 7);<br />
map.setCenter(new GLatLng(9.91355,76.335328), 11 );<br />
}<br />
}</p>
<p>//]]&gt;<br />
&lt;/script&gt;<br />
&lt;/head&gt;<br />
&lt;body onload=&#8221;load()&#8221; onunload=&#8221;GUnload()&#8221;&gt;<br />
&lt;div id=&#8221;map&#8221; style=&#8221;width: 500px; height: 500px&#8221;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Fgoogle-maps-api%2F&amp;linkname=Google%20Maps%20API"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/google-maps-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Favicon icon in the address bar</title>
		<link>http://shahidz.com/favicon-icon-in-the-address-bar/</link>
		<comments>http://shahidz.com/favicon-icon-in-the-address-bar/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 11:54:00 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[Micellanious]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[favicon]]></category>
		<category><![CDATA[image in address bar]]></category>

		<guid isPermaLink="false">http://shahidz.com/?p=5</guid>
		<description><![CDATA[To show icon on the address bar use html tag
Syntax
&#60;link rel=&#8221;shortcut icon&#8221; href=&#8221;URL&#8221; type=&#8221;image/ico&#8221; /&#62;

 Example 
&#60;html&#62;
&#60;title&#62; Icon in address bar &#60;/title&#62;
&#60;link rel=&#8221;shortcut icon&#8221; href=&#8221;image/favicon.ico&#8221; type=&#8221;image/ico&#8221; /&#62;
&#60;/html&#62;
]]></description>
			<content:encoded><![CDATA[<p class="entry"><strong>To show icon on the address bar use html tag</strong></p>
<p><strong>Syntax</strong></p>
<p>&lt;link rel=&#8221;shortcut icon&#8221; href=&#8221;URL&#8221; type=&#8221;image/ico&#8221; /&gt;</p>
<p><a href="http://shahidz.com/wp-content/uploads/2008/02/shahid.jpeg" title="Favicon icon in the browser address bar"><img src="http://shahidz.com/wp-content/uploads/2008/02/shahid.jpeg" alt="Favicon icon in the browser address bar" /></a></p>
<p><strong> Example </strong><br />
&lt;html&gt;<br />
&lt;title&gt; Icon in address bar &lt;/title&gt;<br />
&lt;link rel=&#8221;shortcut icon&#8221; href=&#8221;image/favicon.ico&#8221; type=&#8221;image/ico&#8221; /&gt;<br />
&lt;/html&gt;</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Ffavicon-icon-in-the-address-bar%2F&amp;linkname=Favicon%20icon%20in%20the%20address%20bar"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/favicon-icon-in-the-address-bar/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Installing PHP and PHP modules in Linux</title>
		<link>http://shahidz.com/installing-php-and-php-modules-in-linux/</link>
		<comments>http://shahidz.com/installing-php-and-php-modules-in-linux/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 11:34:01 +0000</pubDate>
		<dc:creator>Shahid</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[php installation]]></category>
		<category><![CDATA[php-modules]]></category>

		<guid isPermaLink="false">http://shahidz.com/?p=4</guid>
		<description><![CDATA[In Redhat and Fedora you can use the command &#8216;yum&#8217;
yum -y install php
yum -y install php-devel
yum -y install php-gd
yum -y install php-imap
yum -y install php-ldap
yum -y install php-mysql
yum -y install php-odbc
yum -y install php-pear
yum -y install php-xml
yum -y install php-xmlrpc
yum -y install curl
yum -y install curl-devel
yum -y install perl-libwww-perl
yum -y install ImageMagick
yum -y install libxml2
yum [...]]]></description>
			<content:encoded><![CDATA[<p>In Redhat and Fedora you can use the command &#8216;yum&#8217;</p>
<p>yum -y install php<br />
yum -y install php-devel<br />
yum -y install php-gd<br />
yum -y install php-imap<br />
yum -y install php-ldap<br />
yum -y install php-mysql<br />
yum -y install php-odbc<br />
yum -y install php-pear<br />
yum -y install php-xml<br />
yum -y install php-xmlrpc<br />
yum -y install curl<br />
yum -y install curl-devel<br />
yum -y install perl-libwww-perl<br />
yum -y install ImageMagick<br />
yum -y install libxml2<br />
yum -y install libxml2-devel<br />
yum -y install httpd</p>
<p>In Ububtu and Debian you can use the command &#8216;apt-get&#8217;</p>
<p>apt-get install php5</p>
<p>apt-get install php5-mysql</p>
<p>apt-get install php5-cli</p>
<p>To search the packages you can use the command apt-cache search &lt;name&gt;</p>
<p>Example :</p>
<p>sudo apt- cache search php5</p>
<p>This will list all the packages for php</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fshahidz.com%2Finstalling-php-and-php-modules-in-linux%2F&amp;linkname=Installing%20PHP%20and%20PHP%20modules%20in%20Linux"><img src="http://shahidz.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://shahidz.com/installing-php-and-php-modules-in-linux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
