<?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>PHP Code</title>
	<atom:link href="http://www.phpcode.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpcode.net</link>
	<description>PHP Codes &#124; PHP Code Snippets &#124; PHP Programming Help</description>
	<lastBuildDate>Tue, 24 Apr 2012 06:27:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Force SSL/https using htaccess</title>
		<link>http://www.phpcode.net/htaccess/force-sslhttps-using-htaccess/</link>
		<comments>http://www.phpcode.net/htaccess/force-sslhttps-using-htaccess/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 06:27:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://www.phpcode.net/?p=744</guid>
		<description><![CDATA[Often its required to redirect users of a site to secure https / ssl page. If you want to redirect whole website to secure website then you can use below code RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.example.com/$1 [R,L] If you need to redirect users to a folder using https / ssl then use [...]]]></description>
			<content:encoded><![CDATA[<p>Often its required to redirect users of a site to secure https / ssl page. If you want to redirect whole website to secure website then you can use below code</p>
<p><code><br />
RewriteEngine On<br />
RewriteCond %{SERVER_PORT} 80<br />
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]<br />
</code></p>
<p>If you need to redirect users to a folder using https / ssl then use the code below.</p>
<p><code><br />
RewriteEngine On<br />
RewriteCond %{SERVER_PORT} 80<br />
RewriteCond %{REQUEST_URI} somefolder<br />
RewriteRule ^(.*)$ https://www.yoursite.com/foldername/$1 [R,L]<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpcode.net/htaccess/force-sslhttps-using-htaccess/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>htaccess to redirect root domain to a subfolder</title>
		<link>http://www.phpcode.net/htaccess/htaccess-to-redirect-root-domain-to-a-subfolder/</link>
		<comments>http://www.phpcode.net/htaccess/htaccess-to-redirect-root-domain-to-a-subfolder/#comments</comments>
		<pubDate>Thu, 22 Mar 2012 05:24:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[htaccess]]></category>

		<guid isPermaLink="false">http://www.phpcode.net/?p=729</guid>
		<description><![CDATA[If you want to redirect your domain yourdomain.com to yourdomain.com/blog then you need to add below code into a .htaccess file in your public_html folder. 1 2 3 4 5 6 7 Add the following lines to that file: RewriteEngine On RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$ RewriteRule ^(/)?$ blog [L]]]></description>
			<content:encoded><![CDATA[<p>If you want to redirect your domain yourdomain.com to yourdomain.com/blog then you need to add below code into a .htaccess file in your public_html folder.</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
</pre>
<pre>Add the following lines to that file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www.)?YourDomain.com$
RewriteRule ^(/)?$ blog [L]</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.phpcode.net/htaccess/htaccess-to-redirect-root-domain-to-a-subfolder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Regular Expressions</title>
		<link>http://www.phpcode.net/php/regular-expressions/</link>
		<comments>http://www.phpcode.net/php/regular-expressions/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 07:18:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Php]]></category>

		<guid isPermaLink="false">http://www.phpcode.net/?p=724</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 &#60;?php $text = &#34;Hello World&#34;; if ( preg_match( &#34;/r.*?d/&#34;, $text, $array ) ) { print &#34;&#60;pre&#62;\n&#34;; print_r( $array ); print &#34;&#60;/pre&#62;\n&#34;; } ?&#62; Output : Array ( [0] => rld ) Get an IP address 1 2 3 4 5 [...]]]></description>
			<content:encoded><![CDATA[<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre>
<pre>&lt;?php
$text = &quot;Hello World&quot;;
if ( preg_match( &quot;/r.*?d/&quot;, $text, $array ) ) {
  print &quot;&lt;pre&gt;\n&quot;;
  print_r( $array );
  print &quot;&lt;/pre&gt;\n&quot;;
}
?&gt;</pre>
</div>
<p>Output :<br />
Array<br />
(<br />
    [0] => rld<br />
)</p>
<p>Get an IP address</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre>
<pre>&lt;?php
$test = &quot;126.122.95.52&quot;;
if ( preg_match( &quot;/(\d+)\.(\d+)\.(\d+)\.(\d+)/&quot;, $test, $arr ) ) {
  print &quot;&lt;pre&gt;\n&quot;;
  print_r( $arr );
  print &quot;&lt;/pre&gt;\n&quot;;
}
?&gt;</pre>
</div>
<p>Output :<br />
Array<br />
(<br />
    [0] => 126.122.95.52<br />
    [1] => 126<br />
    [2] => 122<br />
    [3] => 95<br />
    [4] => 52<br />
)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpcode.net/php/regular-expressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8216;Array&#8217; Example</title>
		<link>http://www.phpcode.net/php/array-example/</link>
		<comments>http://www.phpcode.net/php/array-example/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 11:46:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Php]]></category>

		<guid isPermaLink="false">http://www.phpcode.net/?p=714</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 &#60;?php $arr = array(&#039;one&#039;, 2, &#039;three&#039;); $arr[] = &#039;the fourth element&#039;; echo $arr[3].&#34;&#60;br&#62;&#34;; echo $arr[1]; ?&#62; Output : the fourth element 2 Array indexing 1 2 3 4 5 6 7 8 9 10 11 12 13 &#60;?php $arr1 = array( &#34;Jan &#34;, &#34;Feb [...]]]></description>
			<content:encoded><![CDATA[<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
</pre>
<pre>&lt;?php
$arr = array(&#039;one&#039;, 2, &#039;three&#039;);
$arr[] = &#039;the fourth element&#039;;
echo $arr[3].&quot;&lt;br&gt;&quot;;
echo $arr[1];
?&gt;</pre>
</div>
<p>Output :<br />
the fourth element<br />
2</p>
<p>Array indexing</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
</pre>
<pre>&lt;?php
  $arr1 = array( &quot;Jan &quot;, &quot;Feb &quot;, &quot;Mar &quot; );
  $arr2 = array( &quot;11 &quot;, &quot;12 &quot;, &quot;13 &quot; );
  $arr3 = array( &quot;2001&quot;, &quot;2002&quot;, &quot;2003&quot; );

  echo( $arr1[1] . $arr2[0] . $arr3[1] );
?&gt;</pre>
</div>
<p>Output :<br />
Feb 11 2002</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
</pre>
<pre>&lt;?php
  $arr[0] = 32;
  $arr[1] = 52.15;
  $arr[2] = $arr[0] + $arr[1];

  echo &quot;Result = &quot;.&quot;$arr[0] + $arr[1] = $arr[2]&quot;;
 ?&gt;</pre>
</div>
<p>Output :<br />
Result = 32 + 52.15 = 84.15</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre>
<pre>&lt;?php
$num[&#039;A&#039;] = 12;
$num[&#039;A&#039;]++;
$num[&#039;B&#039;] = 3;

$num[&#039;total&#039;] = $num[&#039;A&#039;] + $num[&#039;B&#039;];
if ($num[&#039;total&#039;] &gt; 15) {
    print &quot;Greater Than 15.&lt;br&gt;&quot;;
}
print &#039;Number is : &#039; . $num[&#039;A&#039;];
?&gt;</pre>
</div>
<p>Output :<br />
Greater Than 15.<br />
Number is : 13</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre>
<pre>&lt;?php
     $arr[] = &quot;PHP&quot;;
     $arr[] = &quot;C&quot;;
     $arr[] = &quot;C++&quot;;
     $arr[] = &quot;Java&quot;;
     $arr[] = &quot;Perl&quot;;
     $arr[] = &quot;Python&quot;;
     $arr[] = &quot;Ruby&quot;;

     foreach($arr as $lang)
     {
          if(!strcmp($lang, &quot;PHP&quot;)){
               print(&quot;&lt;b&gt;&quot; . $lang . &quot;&lt;/b&gt; &lt;br /&gt;&quot;);
          }else{
               print($lang . &quot; &lt;br /&gt;&quot;);
          }
     }
?&gt;</pre>
</div>
<p>Output :<br />
PHP<br />
C<br />
C++<br />
Java<br />
Perl<br />
Python<br />
Ruby </p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpcode.net/php/array-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using this pointer</title>
		<link>http://www.phpcode.net/php/this-pointer/</link>
		<comments>http://www.phpcode.net/php/this-pointer/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 11:16:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Php]]></category>

		<guid isPermaLink="false">http://www.phpcode.net/?p=712</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 &#60;?php class Cat { var $age; function Cat($new_age){ $this-&#62;age = $new_age; } function Birthday( ){ $this-&#62;age++; } } $a = new Cat(1); [...]]]></description>
			<content:encoded><![CDATA[<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre>
<pre>&lt;?php
class Cat {
    var $age;
    function Cat($new_age){
        $this-&gt;age = $new_age;
    }
    function Birthday(  ){
        $this-&gt;age++;
    }
}

$a = new Cat(1);
echo &quot;Age is $a-&gt;age &lt;br /&gt;&quot;;
echo &quot;Birthday&lt;br/&gt;&quot;;

$a-&gt;Birthday(  );
echo &quot;Age is $a-&gt;age &lt;br /&gt;&quot;;
?&gt;</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.phpcode.net/php/this-pointer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Class with a Constructor</title>
		<link>http://www.phpcode.net/php/a-class-with-a-constructor/</link>
		<comments>http://www.phpcode.net/php/a-class-with-a-constructor/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 10:28:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Php]]></category>

		<guid isPermaLink="false">http://www.phpcode.net/?p=701</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 &#60;?php class Item { var $name; function Item( $name=&#34;&#34;) { $this-&#62;name = $name; } function setName( $n) { $this-&#62;name = [...]]]></description>
			<content:encoded><![CDATA[<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
</pre>
<pre>&lt;?php
 class Item {
   var $name;

   function Item( $name=&quot;&quot;) {
     $this-&gt;name = $name;
   }

   function setName( $n) {
     $this-&gt;name = $n;
   }

   function getName () {
     return $this-&gt;name;
   }
 }

 $item = new Item(&quot;5&quot;);
 print $item-&gt;getName ();
?&gt;</pre>
</div>
<p>Output :<br />
5</p>
<p>Invoking parent constructors</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre>
<pre>&lt;?php
class Staff
{
    function __construct()
    {
        echo &quot;&lt;p&gt;Staff constructor called!&lt;/p&gt;&quot;;
    }
}

class Manager extends Staff
{
    function __construct()
    {
        parent::__construct();
        echo &quot;&lt;p&gt;Manager constructor called!&lt;/p&gt;&quot;;
    }
}

$employee = new Manager();
?&gt;</pre>
</div>
<p>Output :<br />
Staff constructor called!<br />
Manager constructor called!</p>
<p></p>
<p>Using Default Constructors</p>
<div class="fvch-code">
<pre class="fvch-line-numbers">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre>
<pre>&lt;?php
class Dog {
    function __construct($name=&#039;No-name&#039;, $breed=&#039;breed unknown&#039;, $price = 23) {
        $this-&gt;name = $name;
        $this-&gt;breed = $breed;
        $this-&gt;price = $price;
    }
}
$aDog = new Dog();
$tweety = new Dog(&#039;A&#039;, &#039;a&#039;); 

printf(&quot;&lt;p&gt;%s is a %s and costs \$%.2f.&lt;/p&gt;\n&quot;,
$aDog-&gt;name, $aDog-&gt;breed, $aDog-&gt;price); 

$tweety-&gt;price = 34.56; 

printf(&quot;&lt;p&gt;%s is a %s and costs \$%.2f.&lt;/p&gt;\n&quot;,
$tweety-&gt;name, $tweety-&gt;breed, $tweety-&gt;price);
?&gt;</pre>
</div>
<p>Output :<br />
No-name is a breed unknown and costs $23.00.<br />
A is a a and costs $34.56.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpcode.net/php/a-class-with-a-constructor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

