<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4664613467486299532</id><updated>2024-09-11T06:22:10.503-07:00</updated><category term="fopen()"/><category term="$_GET"/><category term="$_POST"/><category term="CSV File Reading"/><category term="Client IP"/><category term="Constructor"/><category term="Database Connect"/><category term="Date()"/><category term="Destroy Directory"/><category term="E-Mail"/><category term="Email validation"/><category term="FTP"/><category term="For Loop"/><category term="IP Address"/><category term="Inner Join"/><category term="Left Join"/><category term="List Directory"/><category term="Login Page"/><category term="MySql Join"/><category term="PHP Date"/><category term="PHP Session"/><category term="Redirect"/><category term="Regular Expressions"/><category term="Unique ID"/><category term="Unlike"/><category term="Unset"/><category term="Unzip()"/><category term="array()"/><category term="construct()"/><category term="download"/><category term="explode()"/><category term="fclose()"/><category term="for()"/><category term="fread()"/><category term="fwrite()"/><category term="glob()"/><category term="headers()"/><category term="implode()"/><category term="line break"/><category term="mail()"/><category term="md5()"/><category term="mysql_connect()"/><category term="nl2br()"/><category term="readdir()"/><category term="scandir()"/><category term="server files download"/><category term="session_destroy()"/><category term="session_start()"/><category term="sign in"/><category term="substr_replace()"/><category term="unlink()"/><category term="unset()"/><title type='text'>Knowledge Hut</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>30</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-6235647804452495941</id><published>2013-04-17T03:12:00.000-07:00</published><updated>2013-04-17T03:12:13.960-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="download"/><category scheme="http://www.blogger.com/atom/ns#" term="FTP"/><category scheme="http://www.blogger.com/atom/ns#" term="server files download"/><title type='text'>Download All Files from ftp server</title><content type='html'>&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $local_file = &quot;D:/testing/files/&quot;;&lt;br /&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $ftp_user_name = &quot;ftp_username&quot;;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $ftp_user_pass = &quot;ftp_pswd&quot;;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // set up basic connection&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $conn_id = ftp_connect(&quot;122.00.00.001&quot;);&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // login with username and password&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $mode = ftp_pasv($conn_id, TRUE);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $contents &amp;nbsp;= &amp;nbsp;ftp_nlist($conn_id, &quot;.&quot;);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach($contents as $file)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $local_file=$local_file.$file;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // try to download $remote_file and save it to $handle&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (ftp_get($conn_id, $local_file, $file, FTP_ASCII, 0)) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo &quot;successfully written to $local_file\n&quot;;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } else {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo &quot;There was a problem while downloading $remote_file to $local_file\n&quot;;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // close the connection and the file handler&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ftp_close($conn_id);&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fclose($handle);&lt;/div&gt;
&lt;div&gt;
?&amp;gt; &lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/6235647804452495941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2013/04/download-all-files-from-ftp-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/6235647804452495941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/6235647804452495941'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2013/04/download-all-files-from-ftp-server.html' title='Download All Files from ftp server'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-7706120796917331074</id><published>2012-12-06T05:25:00.001-08:00</published><updated>2013-01-03T04:12:39.125-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Unlike"/><category scheme="http://www.blogger.com/atom/ns#" term="Unset"/><title type='text'>Difference Between Unlink and Unset </title><content type='html'>&lt;h3&gt;
&lt;u&gt;unlink()&lt;/u&gt;&lt;/h3&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;unlink() is a function for file system handling. 
&lt;br /&gt;It will simply delete the file in context.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Example for unlink() :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
$fh = fopen(&#39;file.html&#39;, &#39;a&#39;);
&lt;br /&gt;
fwrite($fh, &#39;Hello world!&#39;);
&lt;br /&gt;
fclose($fh);
&lt;br /&gt;
unlink(&#39;file.html&#39;);
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;u&gt;&lt;b&gt;Unset () &lt;/b&gt;&lt;/u&gt;&lt;/h3&gt;
Unset () is used to destroy a variable in PHP. In can be used to remove a
 single variable, multiple variables, or an element from an array. It is
 phrased as Unset ($remove).
&lt;br /&gt;
Also Known As: Unset Variable, Destroy Variable.&lt;br /&gt;
&lt;br /&gt;
Example for unset() :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
// remove a single variable 
&lt;br /&gt;
unset($a); 
&lt;br /&gt;
&lt;br /&gt;
// remove a single element in an array 
&lt;br /&gt;
unset($my_array[&#39;element&#39;]); 
&lt;br /&gt;
&lt;br /&gt;
// remove multiple variables 
&lt;br /&gt;
unset($a, $b, $c); 
&lt;br /&gt;
?&amp;gt;&amp;nbsp; 
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/7706120796917331074/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/12/difference-between-unlink-and-unset.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/7706120796917331074'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/7706120796917331074'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/12/difference-between-unlink-and-unset.html' title='Difference Between Unlink and Unset '/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-3225511793831661697</id><published>2012-11-27T23:26:00.001-08:00</published><updated>2013-01-03T04:13:20.387-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Left Join"/><category scheme="http://www.blogger.com/atom/ns#" term="MySql Join"/><title type='text'>MySQL LEFT JOIN</title><content type='html'>The LEFT JOIN keyword returns all rows from left table and returns match rows from right table.
&lt;br /&gt;
&lt;h2 class=&quot;specialT&quot;&gt;
family Table:&lt;/h2&gt;
&lt;div class=&quot;display&quot;&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
 &lt;th&gt;Position&lt;/th&gt;&lt;th&gt;Age&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Dad&lt;/td&gt;&lt;td&gt;41&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Mom&lt;/td&gt;&lt;td&gt;35&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Daughter&lt;/td&gt;&lt;td&gt;17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Dog&lt;/td&gt;&lt;td&gt;12&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2 class=&quot;specialT&quot;&gt;
food Table:&lt;/h2&gt;
&lt;div class=&quot;display&quot;&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
 &lt;th&gt;Meal&lt;/th&gt;&lt;th&gt;Position&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Rice&lt;/td&gt;&lt;td&gt;Dad&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Dosa&lt;/td&gt;&lt;td&gt;Mom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Idly&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Egg&lt;/td&gt;&lt;td&gt;Dog &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
When we decide to use a LEFT JOIN in the query instead, all the family members be listed, even if they do not have a favorite dish in our food table.&lt;br /&gt;
This is because a left join will preserve the records of the &quot;left&quot; table.&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;?php 
&lt;/pre&gt;
&lt;pre class=&quot;code&quot;&gt;/* Make a MySQL Connection */
$query = &quot;SELECT family.Position, food.Meal FROM family LEFT JOIN food ON&amp;nbsp;&lt;/pre&gt;
&lt;pre class=&quot;code&quot;&gt;family.Position = food.Position&quot;;
  
$result = mysql_query($query) or die(mysql_error());


// Print out the contents of each row into a table 
while($row = mysql_fetch_array($result)){
 echo $row[&#39;Position&#39;]. &quot; - &quot;. $row[&#39;Meal&#39;];
 echo &quot;
&quot;;
}
?&amp;gt;
&lt;pre class=&quot;code&quot;&gt;Output:-&lt;/pre&gt;
Dad - Dosa
Mom - Rice
Daughter - NULL
Dog - Egg
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/3225511793831661697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/11/mysql-left-join.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/3225511793831661697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/3225511793831661697'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/11/mysql-left-join.html' title='MySQL LEFT JOIN'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-2757297550662188340</id><published>2012-11-27T23:09:00.000-08:00</published><updated>2013-01-03T04:13:59.889-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Inner Join"/><title type='text'>MySQL INNER JOIN</title><content type='html'>The INNER JOIN keyword returns rows when there is at least one match in both tables.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 class=&quot;specialT&quot;&gt;
family Table:&lt;/h2&gt;
&lt;div class=&quot;display&quot;&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
 &lt;th&gt;Position&lt;/th&gt;&lt;th&gt;Age&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Dad&lt;/td&gt;&lt;td&gt;41&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Mom&lt;/td&gt;&lt;td&gt;35&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Daughter&lt;/td&gt;&lt;td&gt;17&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Dog&lt;/td&gt;&lt;td&gt;12&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2 class=&quot;specialT&quot;&gt;
food Table:&lt;/h2&gt;
&lt;div class=&quot;display&quot;&gt;
&lt;table border=&quot;1&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
 &lt;th&gt;Meal&lt;/th&gt;&lt;th&gt;Position&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Rice&lt;/td&gt;&lt;td&gt;Dad&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Dosa&lt;/td&gt;&lt;td&gt;Mom&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Idly&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
 &lt;td&gt;Egg&lt;/td&gt;&lt;td&gt;Dog &lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;br /&gt;
The INNER JOIN keyword returns rows when there is at least one match in both tables. If there are rows in &quot;family&quot; that do not have matches in &quot;food&quot;, those rows will NOT be listed.&lt;br /&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;lt;?php 
&lt;/pre&gt;
&lt;pre class=&quot;code&quot;&gt;/* Make a MySQL Connection */
$query = &quot;SELECT family.Position, food.Meal FROM family INNER JOIN food ON&amp;nbsp;&lt;/pre&gt;
&lt;pre class=&quot;code&quot;&gt;family.Position = food.Position&quot;;
  
$result = mysql_query($query) or die(mysql_error());


// Print out the contents of each row into a table 
while($row = mysql_fetch_array($result)){
 echo $row[&#39;Position&#39;]. &quot; - &quot;. $row[&#39;Meal&#39;];
 echo &quot;
&quot;;
}
?&amp;gt;
&lt;pre class=&quot;code&quot;&gt;Output:-&lt;/pre&gt;
Mom - Rice
Dad - Dosa
Dog - Egg
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/2757297550662188340/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/11/mysql-inner-join.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/2757297550662188340'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/2757297550662188340'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/11/mysql-inner-join.html' title='MySQL INNER JOIN'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-7508642420226114416</id><published>2012-11-02T03:47:00.003-07:00</published><updated>2013-01-03T04:14:29.430-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Date()"/><category scheme="http://www.blogger.com/atom/ns#" term="PHP Date"/><title type='text'>PHP Date()</title><content type='html'>&lt;h2&gt;
PHP Date() - Format the Date&lt;/h2&gt;
The required &lt;i&gt;format&lt;/i&gt; parameter in the date() function specifies how to format the 
date/time.&lt;br /&gt;
Here are some characters that can be used:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;d - Represents the day of the month (01 to 31) &lt;/li&gt;
&lt;li&gt;m - Represents a month (01 to 12)&lt;/li&gt;
&lt;li&gt;Y - Represents a year (in four digits) &lt;/li&gt;
&lt;/ul&gt;
&amp;nbsp;Other characters, like&quot;/&quot;, &quot;.&quot;, or &quot;-&quot; can also be inserted between the 
letters to add additional formatting:&lt;br /&gt;
&amp;lt;?PHP&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
echo date(&quot;Y/m/d&quot;) . &quot;&amp;lt;br/&amp;gt;&quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
echo date(&quot;Y.m.d&quot;) . &quot;&amp;lt;br/&amp;gt;&quot;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
echo date(&quot;Y-m-d&quot;);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;nbsp;The output of the code above could be like this:&lt;br /&gt;
2012/11/01&lt;br /&gt;
2012.11.01&lt;br /&gt;
2012-11-01</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/7508642420226114416/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/11/php-date.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/7508642420226114416'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/7508642420226114416'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/11/php-date.html' title='PHP Date()'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-4010546867415649718</id><published>2012-08-06T01:52:00.000-07:00</published><updated>2013-01-03T04:14:56.688-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="CSV File Reading"/><title type='text'>PHP CSV File Reading</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.csvscr
{
width:718px;
height:200px;
overflow:scroll;
}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;csvscr&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
CSV File Reading In PHP&lt;/h2&gt;
&amp;lt;?php &lt;br /&gt;
$fp = fopen(&#39;example.csv&#39;,&#39;r&#39;) or die(&quot;can&#39;t open file&quot;);&lt;br /&gt;
print &quot;&amp;lt;table&amp;gt;\n&quot;;&lt;br /&gt;
while($csv_line = fgetcsv($fp,1024)) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; print &#39;&amp;lt;tr&amp;gt;&#39;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; for ($i = 0, $j = count($csv_line); $i &amp;lt; $j; $i++) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &#39;&amp;lt;td&amp;gt;&#39;.$csv_line[$i].&#39;&amp;lt;/td&amp;gt;&#39;;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; print &quot;&amp;lt;/tr&amp;gt;\n&quot;;&lt;br /&gt;
}&lt;br /&gt;
print &#39;&amp;lt;/table&amp;gt;\n&#39;;&lt;br /&gt;
fclose($fp) or die(&quot;can&#39;t close file&quot;);&lt;br /&gt;
?&amp;gt;  &lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/4010546867415649718/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/08/php-csv-file-reading.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/4010546867415649718'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/4010546867415649718'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/08/php-csv-file-reading.html' title='PHP CSV File Reading'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-4256521783938019766</id><published>2012-08-01T23:54:00.002-07:00</published><updated>2013-01-03T04:16:03.286-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="md5()"/><category scheme="http://www.blogger.com/atom/ns#" term="Unique ID"/><title type='text'>PHP Unique ID&#39;s</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.unicscr
{
width:718px;
height:300px;
overflow:scroll;
}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;unicscr&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Generating Unique ID&#39;s&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Many of us use the &lt;code&gt;md5()&lt;/code&gt; function for this, even though it&#39;s not exactly meant for this purpose: &lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;// generate unique string&lt;br /&gt;echo md5(time() . mt_rand(1,1000000));&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
There is actually a PHP function named &lt;a href=&quot;http://us2.php.net/manual/en/function.uniqid.php&quot;&gt;uniqid()&lt;/a&gt; that is meant to be used for this.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
// generate unique string&lt;br /&gt;
echo uniqid();&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
// Output like this:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
4bd67c947233e&lt;br /&gt;
&lt;br /&gt;
// generate another unique string&lt;br /&gt;
echo uniqid();&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
// Output like this:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
4bd67c9472340.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
To reduce the chances of getting a duplicate, you can pass a prefix, or the second parameter to increase entropy:&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
// with prefix&lt;br /&gt;
echo uniqid(&#39;myname_&#39;);&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
// Output like this:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
myname_4bd67d6cd8b8f&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// with more entropy&lt;br /&gt;
echo uniqid(&#39;&#39;,true);&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
// Output like this:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
4bd67d6cd8b926.12135106&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
// both&lt;br /&gt;
echo uniqid(&#39;myname_&#39;,true);&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
// Output like this:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
myname_4bd67da367b650.43684647&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/4256521783938019766/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/08/php-unique-ids.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/4256521783938019766'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/4256521783938019766'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/08/php-unique-ids.html' title='PHP Unique ID&#39;s'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-4276416861729283465</id><published>2012-08-01T23:47:00.000-07:00</published><updated>2013-01-03T04:16:30.095-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="glob()"/><category scheme="http://www.blogger.com/atom/ns#" term="scandir()"/><title type='text'>PHP Glob() to Find Files</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.globscr
{
width:718px;
height:300px;
overflow:scroll;
}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;globscr&quot;&gt;
&lt;h2&gt;
Using Glob() to Find Files&lt;/h2&gt;
Many PHP functions have long and descriptive names. However it may be hard to tell what a function named &lt;a href=&quot;http://us.php.net/manual/en/function.glob.php&quot;&gt;glob()&lt;/a&gt; does unless you are already familiar with that term from elsewhere.&lt;br /&gt;
Think of it like a more capable version of the &lt;a href=&quot;http://php.net/manual/en/function.scandir.php&quot;&gt;scandir()&lt;/a&gt; function. It can let you search for files by using patterns.&lt;br /&gt;
&lt;br /&gt;
// get all php files&lt;br /&gt;
$files = glob(&#39;*.php&#39;);&lt;br /&gt;
print_r($files);&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Output: &lt;/h4&gt;
Array&lt;br /&gt;
(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [0] =&amp;gt; php1.php&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [1] =&amp;gt; phptesting.php&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [2] =&amp;gt; post_output.php&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [3] =&amp;gt; test.php&lt;br /&gt;
)&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
To fetch multiple file types like this: &lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
// get all php files AND txt files&lt;br /&gt;
$files = glob(&#39;*.{php,txt}&#39;, GLOB_BRACE);&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
print_r($files);&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Output:&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Array&lt;br /&gt;
(&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [0] =&amp;gt; phptest.php&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [1] =&amp;gt; function.php&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [2] =&amp;gt; post_output.php&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [3] =&amp;gt; test.php&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [4] =&amp;gt; log.txt&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [5] =&amp;gt; test.txt&lt;br /&gt;
)&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/4276416861729283465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/08/php-glob-to-find-files.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/4276416861729283465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/4276416861729283465'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/08/php-glob-to-find-files.html' title='PHP Glob() to Find Files'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-311373957830701520</id><published>2012-08-01T23:37:00.000-07:00</published><updated>2013-01-03T04:17:06.098-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="headers()"/><category scheme="http://www.blogger.com/atom/ns#" term="Redirect"/><title type='text'>PHP Redirect To Another URL</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.redirscr
{
width:718px;
height:200px;
overflow:scroll;
}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;redirscr&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
How do I redirect with PHP script?&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Using headers() method, you can easily transferred to the new page 
without having to click a link to continue.  This is also useful for 
search engines. Remember that header() must be called before any actual 
output is sent, either by normal HTML tags, blank lines in a file, or 
from PHP. It is a very common error to read code with include(), or 
require(), functions, or another file access function, and have spaces 
or empty lines that are output before header() is called. The same 
problem exists when using a single PHP/HTML file.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2&gt;
PHP Redirect Script&lt;/h2&gt;
You can easily redirect using following code:&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&amp;nbsp;
&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;/* Redirect browser */&lt;/span&gt;
&lt;a href=&quot;http://www.php.net/header&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;header&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: red;&quot;&gt;&quot;Location: http://www.yoursitename.com/&quot;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;)&lt;/span&gt;;
&lt;span style=&quot;color: grey; font-style: italic;&quot;&gt;/* Make sure that code below does not get executed when we redirect. */&lt;/span&gt;
&lt;a href=&quot;http://www.php.net/exit&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;exit&lt;/span&gt;&lt;/a&gt;;
&lt;span style=&quot;color: black; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/311373957830701520/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/08/php-redirect-to-another-url.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/311373957830701520'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/311373957830701520'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/08/php-redirect-to-another-url.html' title='PHP Redirect To Another URL'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-7540496883207564904</id><published>2012-07-30T22:39:00.000-07:00</published><updated>2013-01-03T04:17:32.864-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fopen()"/><category scheme="http://www.blogger.com/atom/ns#" term="fread()"/><title type='text'>PHP fread Function</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.wfilescr
{
width:718px;
height:200px;
overflow:scroll;
}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;wfilescr&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
PHP - File Read&lt;/h2&gt;
If you wanted to read all the data from the file, then you need to get the
size of the file.  The &lt;i&gt;filesize&lt;/i&gt; function returns the length of a file, in bytes,
which is just what we need!  The &lt;i&gt;filesize&lt;/i&gt; function requires the name of the file that is to be sized up.&lt;br /&gt;
&lt;div class=&quot;codewrap&quot;&gt;
&lt;h2 class=&quot;specialT&quot;&gt;
PHP Code:&lt;/h2&gt;
&lt;pre class=&quot;code&quot;&gt;$myFile = &quot;testfile.txt&quot;;
$fh = fopen($myFile, &#39;r&#39;);
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;
&lt;/pre&gt;
&lt;/div&gt;
&lt;h2 class=&quot;specialT&quot;&gt;
Output:&lt;/h2&gt;
&lt;div class=&quot;display&quot;&gt;
Floppy Jalopy Pointy Pinto&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;display&quot;&gt;
&lt;/div&gt;
&lt;b&gt;Note:&lt;/b&gt; It is all on one line because our &quot;testfile.txt&quot; file did not have a &amp;lt;br /&amp;gt; tag to
create an HTML line break.
Now the entire contents of the &lt;i&gt;testfile.txt&lt;/i&gt; file is stored in the string variable
&lt;i&gt;$theData&lt;/i&gt;.
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/7540496883207564904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-fread-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/7540496883207564904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/7540496883207564904'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-fread-function.html' title='PHP fread Function'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-6394217180756208870</id><published>2012-07-30T22:34:00.004-07:00</published><updated>2013-01-03T04:17:58.096-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fwrite()"/><title type='text'>PHP fwrite Function</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.filewscr
{
width:718px;
height:200px;
overflow:scroll;
}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;filewscr&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
PHP - File Write&lt;/h2&gt;
We can use php to write to a text file.  The &lt;i&gt;fwrite&lt;/i&gt; function allows
data to be written to any type of file. Fwrite&#39;s first
parameter is the file handle and its second parameter is the string of data that is to
be written.  Just give the function those two bits of information and you&#39;re good to go!
&lt;br /&gt;
Below we are writing a couple of names into our test file &lt;i&gt;testfile.txt&lt;/i&gt; and separating
them with a carriaged return.  
&lt;br /&gt;
&lt;div class=&quot;codewrap&quot;&gt;
&lt;h2 class=&quot;specialT&quot;&gt;
PHP Code:&lt;/h2&gt;
&lt;pre class=&quot;code&quot;&gt;$myFile = &quot;testfile.txt&quot;;
$fh = fopen($myFile, &#39;w&#39;) or die(&quot;can&#39;t open file&quot;);
$stringData = &quot;News Paper\n&quot;;
fwrite($fh, $stringData);
$stringData = &quot;Note Book\n&quot;;
fwrite($fh, $stringData);
fclose($fh);
&lt;/pre&gt;
&lt;/div&gt;
The &lt;i&gt;$fh&lt;/i&gt; variable contains the file handle for &lt;i&gt;testfile.txt&lt;/i&gt;.  
The file handle knows the current file pointer, which for writing, starts out at the beginning of the file.&lt;br /&gt;
&lt;br /&gt;
We wrote to the file &lt;i&gt;testfile.txt&lt;/i&gt; twice.  Each time we wrote to the file
we sent the string &lt;i&gt;$stringData&lt;/i&gt; that first contained &lt;i&gt;News Paper&lt;/i&gt; and second contained
&lt;i&gt;Note Book&lt;/i&gt;.  After we finished writing we closed the file using the &lt;i&gt;fclose&lt;/i&gt; function.&amp;nbsp;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/6394217180756208870/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-fwrite-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/6394217180756208870'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/6394217180756208870'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-fwrite-function.html' title='PHP fwrite Function'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-236215468959565958</id><published>2012-07-30T22:28:00.000-07:00</published><updated>2013-01-03T04:18:32.290-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="fclose()"/><category scheme="http://www.blogger.com/atom/ns#" term="fopen()"/><title type='text'>PHP Create a File</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.opfilescr
{
width:718px;
height:350px;
overflow:scroll;
}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;opfilescr&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Create a File&lt;/h2&gt;
The &lt;i&gt;fopen&lt;/i&gt; function needs two important pieces of information to operate correctly.  First,
we must supply it with the name of the file that we want it to open.  Secondly, we must tell the function
what we plan on doing with that file (i.e. read from the file, write information, etc).&lt;br /&gt;
Since we want to create a file, we must supply a file name and tell PHP that we want to write
to the file.  Note: We have to tell PHP we are writing to the file, otherwise it will not create a new file.
&lt;br /&gt;
&lt;div class=&quot;codewrap&quot;&gt;
&lt;h2 class=&quot;specialT&quot;&gt;
PHP Code:&lt;/h2&gt;
&lt;pre class=&quot;code&quot;&gt;$ourFileName = &quot;testfile.txt&quot;;
$ourFileHandle = &lt;span style=&quot;color: red;&quot;&gt;fopen($ourFileName, &#39;w&#39;)&lt;/span&gt; or die(&quot;can&#39;t open file&quot;);
fclose($ourFileHandle);&lt;/pre&gt;
&lt;pre class=&quot;code&quot;&gt;&amp;nbsp;&lt;/pre&gt;
&lt;/div&gt;
The file &quot;testfile.txt&quot; should be created in the same directory where
 this PHP code resides.  PHP will see that
&quot;testFile.txt&quot; does not exist and will create it after running this 
code.  There&#39;s a lot of information in those three lines of code, let&#39;s 
make sure you understand it.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;$ourFileName = &quot;testfile.txt&quot;;&lt;/b&gt;
  Here we create the name of our file, &quot;testfile.txt&quot; and store it into a &lt;a href=&quot;http://www.tizag.com/phpT/strings.php&quot;&gt;PHP String&lt;/a&gt; variable &lt;i&gt;$ourFileName&lt;/i&gt;.&lt;br /&gt;

 &lt;/li&gt;
&lt;li&gt;&lt;b&gt;$ourFileHandle = fopen($ourFileName, &#39;w&#39;)&lt;/b&gt; or die(&quot;can&#39;t open file&quot;);
  This bit of code actually has two parts.  First we use the function &lt;i&gt;fopen&lt;/i&gt; and give it two arguments: our file name and we inform
  PHP that we want to write by passing the character &quot;w&quot;.&lt;br /&gt;

  Second, the &lt;i&gt;fopen&lt;/i&gt; function returns what is called a &lt;i&gt;file handle&lt;/i&gt;, which will allow us to manipulate the file.  We save
  the file handle into the &lt;i&gt;$ourFileHandle&lt;/i&gt; variable.  We will talk more about file handles later on.&lt;br /&gt;

 &lt;/li&gt;
&lt;li&gt;&lt;b&gt;fclose($ourFileHandle);&lt;/b&gt;
  We close the file that was opened.  &lt;i&gt;fclose&lt;/i&gt; takes the file handle that is to be closed. We will talk more about this more in the file closing lesson.&lt;br /&gt;

 &lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/236215468959565958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-create-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/236215468959565958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/236215468959565958'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-create-file.html' title='PHP Create a File'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-1909233718661656988</id><published>2012-07-29T23:48:00.002-07:00</published><updated>2013-01-03T04:19:13.942-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Unzip()"/><title type='text'>PHP Unzip Zip File</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.unzipscr
{
width:718px;
height:200px;
overflow:scroll;
}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;unzipscr&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Unzip Zip File&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
/**********************&lt;br /&gt;
*@file - path to zip file&lt;br /&gt;
*@destination - destination directory for unzipped files&lt;br /&gt;
*/&lt;br /&gt;
function unzip_file($file, $destination){&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // create object&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $zip = new ZipArchive() ;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // open archive&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($zip-&amp;gt;open($file) !== TRUE) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; die (’Could not open archive’);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // extract contents to destination directory&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $zip-&amp;gt;extractTo($destination);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; // close archive&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $zip-&amp;gt;close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &#39;Archive extracted to directory&#39;;&lt;br /&gt;
} &lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/1909233718661656988/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-unzip-zip-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/1909233718661656988'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/1909233718661656988'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-unzip-zip-file.html' title='PHP Unzip Zip File'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-3543425946718959614</id><published>2012-07-29T23:42:00.000-07:00</published><updated>2013-01-03T04:19:39.673-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Client IP"/><category scheme="http://www.blogger.com/atom/ns#" term="IP Address"/><title type='text'>PHP Get Real IP Address of Client</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.ipscr
{
width:718px;
height:250px;
overflow:scroll;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;ipscr&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Get Real IP Address of Client&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
This function will fetch the real IP address of the user even if he is behind a proxy server. &lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
function getRealIpAddr()&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (!empty($_SERVER[&#39;HTTP_CLIENT_IP&#39;]))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; $ip=$_SERVER[&#39;HTTP_CLIENT_IP&#39;];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; elseif (!empty($_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;]))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; //to check ip is pass from proxy&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; $ip=$_SERVER[&#39;HTTP_X_FORWARDED_FOR&#39;];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; $ip=$_SERVER[&#39;REMOTE_ADDR&#39;];&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; return $ip;&lt;br /&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/3543425946718959614/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-get-real-ip-address-of-client.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/3543425946718959614'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/3543425946718959614'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-get-real-ip-address-of-client.html' title='PHP Get Real IP Address of Client'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-8050370032533463201</id><published>2012-07-29T23:39:00.000-07:00</published><updated>2013-01-03T04:20:13.363-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Destroy Directory"/><category scheme="http://www.blogger.com/atom/ns#" term="unlink()"/><title type='text'>PHP Destroy Directory</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.destroyscr
{
width:718px;
height:250px;
overflow:scroll;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;destroyscr&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Destroy Directory&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Delete a directory including its contents.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
/*****&lt;br /&gt;
*@dir - Directory to destroy&lt;br /&gt;
*@virtual[optional]- whether a virtual directory&lt;br /&gt;
*/&lt;br /&gt;
function destroyDir($dir, $virtual = false)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $ds = DIRECTORY_SEPARATOR;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $dir = $virtual ? realpath($dir) : $dir;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; $dir = substr($dir, -1) == $ds ? substr($dir, 0, -1) : $dir;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if (is_dir($dir) &amp;amp;&amp;amp; $handle = opendir($dir))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;while ($file = readdir($handle))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;if ($file == &#39;.&#39; || $file == &#39;..&#39;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;continue;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;elseif (is_dir($dir.$ds.$file))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;destroyDir($dir.$ds.$file);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;unlink($dir.$ds.$file);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;closedir($handle);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;rmdir($dir);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return true;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;return false;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/8050370032533463201/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-destroy-directory.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/8050370032533463201'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/8050370032533463201'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-destroy-directory.html' title='PHP Destroy Directory'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-11658906342178034</id><published>2012-07-29T23:37:00.000-07:00</published><updated>2013-01-03T04:21:23.278-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="List Directory"/><category scheme="http://www.blogger.com/atom/ns#" term="readdir()"/><title type='text'>PHP List Directory Contents</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.dirtscr
{
width:718px;
height:200px;
overflow:scroll;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;dirtscr&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
List Directory Contents&amp;nbsp;&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
function list_files($dir)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(is_dir($dir))&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if($handle = opendir($dir))&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; while(($file = readdir($handle)) !== false)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if($file != &quot;.&quot; &amp;amp;&amp;amp; $file != &quot;..&quot; &amp;amp;&amp;amp; $file != &quot;Thumbs.db&quot;)&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; echo &#39;&amp;lt;a target=&quot;_blank&quot; href=&quot;&#39;.$dir.$file.&#39;&quot;&amp;gt;&#39;.$file.&#39;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&#39;.&quot;\n&quot;;&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; closedir($handle);&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/11658906342178034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-list-directory-contents.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/11658906342178034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/11658906342178034'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-list-directory-contents.html' title='PHP List Directory Contents'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-2523919449176486045</id><published>2012-07-27T02:28:00.004-07:00</published><updated>2013-01-03T04:20:51.195-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="line break"/><category scheme="http://www.blogger.com/atom/ns#" term="nl2br()"/><title type='text'>HTML line break</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.htmlscr
{
width:718px;
height:200px;
overflow:scroll;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;htmlscr&quot;&gt;
&lt;h2&gt;





Inserts HTML line breaks before all newlines in a string&lt;/h2&gt;
This code is very useful when we insert large content with number of new lines in the database table.&lt;br /&gt;
In case of html line, it inserts &amp;lt;br /&amp;gt; for all \n.&lt;br /&gt;
&lt;div class=&quot;fvch-code&quot;&gt;
&lt;pre class=&quot;fvch-line-numbers&quot;&gt;&lt;/pre&gt;
&lt;pre&gt;&amp;lt;?php
echo nl2br(&quot;Hello \n World&quot;);
?&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;b&gt;OUTPUT will be&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;fvch-code&quot;&gt;
&lt;pre&gt;Hello
World&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/2523919449176486045/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/html-line-break.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/2523919449176486045'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/2523919449176486045'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/html-line-break.html' title='HTML line break'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-8833993797505268279</id><published>2012-07-27T02:24:00.004-07:00</published><updated>2013-01-03T04:22:24.033-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Login Page"/><category scheme="http://www.blogger.com/atom/ns#" term="sign in"/><title type='text'>PHP Login Page using Session</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.loginscr
{
width:718px;
height:350px;
overflow:scroll;
}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;loginscr&quot;&gt;
&lt;h2&gt;
A Simple Login Page using Session&lt;/h2&gt;
This page aims to show a simple ‘log in’ or ‘sign in’ script written in PHP&lt;br /&gt;
&lt;div class=&quot;fvch-code&quot;&gt;
&lt;pre class=&quot;fvch-line-numbers&quot;&gt;&lt;/pre&gt;
&lt;pre&gt;&amp;lt;?php
session_start();
if (isset($_POST[&quot;submit&quot;])) {
  if ($_POST[&quot;user&quot;] == &quot;nilanjan&quot; &amp;amp;&amp;amp; $_POST[&quot;pass&quot;] == &quot;banerjee&quot;) {
    $_SESSION[&quot;usernm&quot;] = $_POST[&quot;user&quot;];
  }
}
?&amp;gt;

&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;User Authentication&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;?php
if (isset($_SESSION[&quot;usernm&quot;])) {
  echo(&quot;You are logged in!&quot;);
} else {
?&amp;gt;
&amp;lt;form method=&quot;post&quot;&amp;gt;
&amp;lt;input type=&quot;text&quot; name=&quot;user&quot; /&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;input type=&quot;password&quot; name=&quot;pass&quot; /&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Login&quot; /&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;?php
}
?&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/8833993797505268279/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-login-page-using-session.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/8833993797505268279'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/8833993797505268279'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-login-page-using-session.html' title='PHP Login Page using Session'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-2811471889142168479</id><published>2012-07-27T02:22:00.002-07:00</published><updated>2013-01-03T04:22:57.659-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Email validation"/><title type='text'>PHP Email validation</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.emavscr
{
width:718px;
height:250px;
overflow:scroll;
}
&lt;/style&gt;&lt;br /&gt;
&lt;div class=&quot;emavscr&quot;&gt;
&lt;h2&gt;

Email validation with Regular Expressions&lt;/h2&gt;
This is also case-insensitive,
 so it will treat all characters as lower case. It is a really easy way 
to check the syntax and format of an email address.&lt;br /&gt;
&lt;div class=&quot;fvch-code&quot;&gt;
&lt;pre class=&quot;fvch-line-numbers&quot;&gt;&lt;/pre&gt;
&lt;pre&gt;&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;?php
if (isset($_POST[&#39;posted&#39;])) {
   $email = $_POST[&#39;email&#39;];
   $theresults = ereg(&quot;^[^@ ]+@[^@ ]+\.[^@ \.]+$&quot;, $email, $trashed);   //&quot;\w+@\w+.\w+$&quot;
   if ($theresults) {
      $isamatch = &quot;Valid&quot;;
   } else {
      $isamatch = &quot;Invalid&quot;;
   }
   echo &quot;Email address validation says $email is &quot; . $isamatch;
}
?&amp;gt;

&amp;lt;form action=&quot;&amp;lt;?php echo $_SERVER[&#39;PHP_SELF&#39;]; ?&amp;gt;&quot; method=&quot;POST&quot;&amp;gt;
&amp;lt;input type=&quot;hidden&quot; name=&quot;posted&quot; value=&quot;true&quot;&amp;gt;
Enter your email address for validation:
&amp;lt;input type=&quot;text&quot; name=&quot;email&quot; value=&quot;name@example.com&quot;&amp;gt;
&amp;lt;input type=&quot;submit&quot; value=&quot;Validate&quot;&amp;gt;
&amp;lt;/form&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/2811471889142168479/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-email-validation.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/2811471889142168479'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/2811471889142168479'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-email-validation.html' title='PHP Email validation'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-3258522369767903567</id><published>2012-07-27T02:16:00.000-07:00</published><updated>2013-01-03T04:23:10.819-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="substr_replace()"/><title type='text'>PHP substr_replace()</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.substrscr
{
width:718px;
height:250px;
overflow:scroll;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;substrscr&quot;&gt;
&lt;pre&gt;&amp;lt;?php
    $id = &quot;asdfasdf&quot;;
    $id = substr_replace( $id, &quot;00&quot;, 3, 2);
    print &quot;New id number: $id&amp;lt;br/&amp;gt;&quot;;
?&amp;gt;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Output:&lt;/h3&gt;
New id number: asd00sdf&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;fvch-code&quot;&gt;
&lt;pre class=&quot;fvch-line-numbers&quot;&gt;&lt;/pre&gt;
&lt;pre&gt;&amp;lt;?php
$mystring = substr_replace(&quot;Hello World&quot;, &quot;asdf&quot;, 0, 0);
echo $mystring . &quot;&amp;lt;br /&amp;gt;&quot;; 

$mystring = substr_replace(&quot;Hello World&quot;, &quot;0 w0&quot;, 4, 4);
echo $mystring;
?&amp;gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Output :&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
asdfHello World&lt;br /&gt;
Hell0 w0rld&lt;/div&gt;
&lt;div class=&quot;fvch-code&quot;&gt;
&lt;pre&gt;&amp;lt;?php
$favs = &quot; is good boy.&quot;;
$name = &quot;Ram&quot;;
$favs = substr_replace($favs, $name, 0, 0);
print $favs;
?&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Output :&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Ram is good boy.&lt;/div&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/3258522369767903567/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-substrreplace.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/3258522369767903567'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/3258522369767903567'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-substrreplace.html' title='PHP substr_replace()'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-222408067159339463</id><published>2012-07-27T02:10:00.003-07:00</published><updated>2013-01-03T04:23:34.394-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="explode()"/><category scheme="http://www.blogger.com/atom/ns#" term="implode()"/><title type='text'>PHP explode() and implode()</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.expscr
{
width:718px;
height:350px;
overflow:scroll;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;expscr&quot;&gt;
&lt;h2&gt;




Using the explode() and implode() Function&lt;/h2&gt;
&lt;pre&gt;&amp;lt;?php
    $str = &quot;Colonia De Sant Jordi.&quot;;

    $pieces = explode(&quot; &quot;, $str);

    echo &quot;Nodes: &amp;lt;BR/&amp;gt;\n&quot;;
    foreach($pieces as $name) {
        echo trim($name) . &quot;&amp;lt;BR/&amp;gt;\n&quot;;
    }
?&amp;gt;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;


Output:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Nodes:&lt;br /&gt;
Colonia&lt;br /&gt;
De&lt;br /&gt;
Sant&lt;br /&gt;
Jordi.&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;


Using explode() with date()&lt;/h3&gt;
&lt;pre&gt;&amp;lt;?php
$ar = explode(&#39;|&#39;,date(&quot;h a|F d, Y&quot;));
echo &quot;It&#39;s after $ar[0] on $ar[1]&quot;;
?&amp;gt;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;


Output:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
It’s after 03 pm on November 04, 2011&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;


Using implode()&lt;/h3&gt;
&lt;pre&gt;&amp;lt;?php
$arr[0] = &quot;Colonia&quot;;
$arr[1] = &quot;De&quot;;
$arr[2] = &quot;Sant&quot;;
$arr[3] = &quot;Jordi.&quot;;
$str = implode(&quot; &quot;, $arr);
print(&quot;$str&amp;lt;BR&amp;gt;&quot;);
?&amp;gt;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;


Output:&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Colonia De Sant Jordi.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/222408067159339463/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-explode-and-implode.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/222408067159339463'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/222408067159339463'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-explode-and-implode.html' title='PHP explode() and implode()'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-3829234113111365308</id><published>2012-07-27T02:03:00.000-07:00</published><updated>2013-01-03T04:24:08.192-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="construct()"/><category scheme="http://www.blogger.com/atom/ns#" term="Constructor"/><title type='text'>PHP Constructor</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.emailscr
{
width:718px;
height:350px;
overflow:scroll;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;emailscr&quot;&gt;
&lt;h2&gt;



A Class with a Constructor &lt;/h2&gt;
&lt;pre&gt;&amp;lt;?php
 class Item {
   var $name;

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

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

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

 $item = new Item(&quot;5&quot;);
 print $item-&amp;gt;getName ();
?&amp;gt;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;



Output :&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
5&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;



Invoking parent constructors &lt;/h3&gt;
&lt;pre&gt;&amp;lt;?php
class Staff
{
    function __construct()
    {
        echo &quot;&amp;lt;p&amp;gt;Staff constructor called!&amp;lt;/p&amp;gt;&quot;;
    }
}

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

$employee = new Manager();
?&amp;gt;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;



Output :&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Staff constructor called!&lt;br /&gt;
Manager constructor called!&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.consscr
{
width:718px;
height:150px;
overflow:scroll;
}
&lt;/style&gt;

&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/3829234113111365308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-constructor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/3829234113111365308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/3829234113111365308'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-constructor.html' title='PHP Constructor'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-6088195008282478802</id><published>2012-07-27T01:59:00.001-07:00</published><updated>2013-01-03T04:24:27.678-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="array()"/><title type='text'>PHP Array</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2&gt;


‘Array’ Example&lt;/h2&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.arrscr
{
width:718px;
height:350px;
overflow:scroll;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;arrscr&quot;&gt;
&lt;pre&gt;&amp;lt;?php
$arr = array(&#39;one&#39;, 2, &#39;three&#39;);
$arr[] = &#39;the fourth element&#39;;
echo $arr[3].&quot;&amp;lt;br&amp;gt;&quot;;
echo $arr[1];
?&amp;gt;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;

Output :&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
the fourth element&lt;br /&gt;
2&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Array indexing&lt;/h3&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Example 1 &lt;/span&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;pre&gt;&amp;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] );
?&amp;gt;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Output :&lt;/h3&gt;
Feb 11 2002.&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Example 2&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;pre&gt;&amp;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;;
 ?&amp;gt;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Output :&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Result = 32 + 52.15 = 84.15.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Example 3&lt;/span&gt;&lt;/h4&gt;
&lt;pre&gt;&amp;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;&amp;lt;b&amp;gt;&quot; . $lang . &quot;&amp;lt;/b&amp;gt; &amp;lt;br /&amp;gt;&quot;);
          }else{
               print($lang . &quot; &amp;lt;br /&amp;gt;&quot;);
          }
     }
?&amp;gt;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Output :&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
PHP&lt;br /&gt;
C&lt;br /&gt;
C++&lt;br /&gt;
Java&lt;br /&gt;
Perl&lt;br /&gt;
Python&lt;br /&gt;
Ruby &lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/6088195008282478802/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/6088195008282478802'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/6088195008282478802'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-array.html' title='PHP Array'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-3118903848324297868</id><published>2012-07-27T01:52:00.000-07:00</published><updated>2013-01-03T04:25:01.020-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Regular Expressions"/><title type='text'>PHP Regular Expressions</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.regularscr
{
width:718px;
height:250px;
overflow:scroll;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;regularscr&quot;&gt;
&lt;pre&gt;&amp;lt;?php
$text = &quot;Hello World&quot;;
if ( preg_match( &quot;/r.*?d/&quot;, $text, $array ) )&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;{
  print &quot;&amp;lt;pre&amp;gt;\n&quot;;
  print_r( $array );
  print &quot;&amp;lt;/pre&amp;gt;\n&quot;;
 }
?&amp;gt;&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;

Output :&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Array&lt;br /&gt;
(&lt;br /&gt;
[0] =&amp;gt; rld&lt;br /&gt;
)&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;

Get an IP address &lt;/h3&gt;
&lt;pre&gt;&amp;lt;?php
$test = &quot;126.122.95.52&quot;;
if ( preg_match( &quot;/(\d+)\.(\d+)\.(\d+)\.(\d+)/&quot;, $test, $arr ) )&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;{
  print &quot;&amp;lt;pre&amp;gt;\n&quot;;
  print_r( $arr );
  print &quot;&amp;lt;/pre&amp;gt;\n&quot;;
 }
?&amp;gt;&lt;/pre&gt;
&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;

Output :&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Array&lt;br /&gt;
(&lt;br /&gt;
[0] =&amp;gt; 126.122.95.52&lt;br /&gt;
[1] =&amp;gt; 126&lt;br /&gt;
[2] =&amp;gt; 122&lt;br /&gt;
[3] =&amp;gt; 95&lt;br /&gt;
[4] =&amp;gt; 52&lt;br /&gt;
)&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/3118903848324297868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-regular-expressions.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/3118903848324297868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/3118903848324297868'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-regular-expressions.html' title='PHP Regular Expressions'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4664613467486299532.post-7517475512473895753</id><published>2012-07-24T00:20:00.003-07:00</published><updated>2013-01-03T04:25:19.564-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="$_POST"/><title type='text'>PHP $_POST Function</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
div.postscr
{
width:718px;
height:250px;
overflow:scroll;
}
&lt;/style&gt;

&lt;br /&gt;
&lt;div class=&quot;postscr&quot;&gt;
&lt;h2&gt;





The $_POST Variable&lt;/h2&gt;
The predefined $_POST variable is used to collect values from a form sent with 
method=&quot;post&quot;.&lt;br /&gt;
Information sent from a form with the POST method is invisible to others and 
has no limits on the amount of information to send.&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt; However, there is an 8 Mb max size for the POST method, by default 
(can be changed by setting the post_max_size in the php.ini file).&lt;br /&gt;
&lt;h3&gt;






Example&lt;/h3&gt;
&lt;div class=&quot;code notranslate&quot;&gt;
&lt;div&gt;
&amp;lt;form action=&quot;welcome.php&quot; method=&quot;post&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Name: &amp;lt;input type=&quot;text&quot; name=&quot;fname&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Age: &amp;lt;input type=&quot;text&quot; name=&quot;age&quot; /&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type=&quot;submit&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;/div&gt;
&lt;/div&gt;
When the user clicks the &quot;Submit&quot; button, the URL will look 
like this:&lt;br /&gt;
&lt;div class=&quot;code notranslate&quot;&gt;
&lt;div&gt;
http://www.phppostexample.com/welcome.php&lt;/div&gt;
&lt;/div&gt;
The &quot;welcome.php&quot; file can now use the $_POST variable to collect form data 
(the names of the form fields will automatically be the keys in the $_POST 
array):&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;code notranslate&quot;&gt;
&lt;div&gt;
Welcome &amp;lt;?php echo $_POST[&quot;fname&quot;]; ?&amp;gt;!&amp;lt;br /&amp;gt;&lt;br /&gt;
You are &amp;lt;?php echo $_POST[&quot;age&quot;]; ?&amp;gt; years old.&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;h3&gt;



Output&amp;nbsp;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Welcome John.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
You are 27 years old!&lt;br /&gt;
&amp;nbsp;--------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;h2&gt;



The PHP $_REQUEST Variable&lt;/h2&gt;
The predefined $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.&lt;br /&gt;
The $_REQUEST variable can be used to collect form data sent 
with both the GET and POST methods.&lt;br /&gt;
&lt;h3&gt;



Example&lt;/h3&gt;
&lt;div class=&quot;code notranslate&quot;&gt;
&lt;div&gt;
Welcome &amp;lt;?php echo $_REQUEST[&quot;fname&quot;]; ?&amp;gt;!&amp;lt;br /&amp;gt;&lt;br /&gt;
You are &amp;lt;?php echo $_REQUEST[&quot;age&quot;]; ?&amp;gt; years old.
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h3&gt;



Output&amp;nbsp;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Welcome John.&lt;/div&gt;
You are 27 years old!&amp;nbsp; &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://knowledgehut.blogspot.com/feeds/7517475512473895753/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-post-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/7517475512473895753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4664613467486299532/posts/default/7517475512473895753'/><link rel='alternate' type='text/html' href='http://knowledgehut.blogspot.com/2012/07/php-post-function.html' title='PHP $_POST Function'/><author><name>Unknown</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>