<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' version='2.0'><channel><atom:id>tag:blogger.com,1999:blog-2865552588131115943</atom:id><lastBuildDate>Mon, 05 Oct 2009 10:27:37 +0000</lastBuildDate><title>PHP Codes</title><description></description><link>http://php-teacher.blogspot.com/</link><managingEditor>noreply@blogger.com (PHP Codes)</managingEditor><generator>Blogger</generator><openSearch:totalResults>28</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-6346078877957574678</guid><pubDate>Thu, 06 Nov 2008 15:57:00 +0000</pubDate><atom:updated>2008-11-06T07:59:37.635-08:00</atom:updated><title>Using session in PHP</title><description>Keeping in mind the fact that Internet is a stateless platform and every request for a web page is treated as unique, there is a serious need of a tool to maintain the state. Otherwise, it will be a messy situation to keep track of requests made by a particular user. The good news is that use of PHP session serves the solution to this problem. This session variable is of great importance for web applications like shopping carts and is considered as equivalent to cookies, other significant way of maintaining the state.&lt;br /&gt;&lt;br /&gt;What Is PHP Session Capable Of&lt;br /&gt;&lt;br /&gt;PHP session is capable of storing the information in the form of session variables, in order to handle the ever-increasing traffic on a website. For instance, consider a shopping website, with products scattered in different categories and different pages. In such a situation, a user may switch from one page t another and keep on adding products from different pages to his or her shopping cart.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-6346078877957574678?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/11/using-session-in-php.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-2275600408986693965</guid><pubDate>Thu, 06 Nov 2008 15:54:00 +0000</pubDate><atom:updated>2008-11-06T07:57:25.922-08:00</atom:updated><title>Memcache</title><description>Memcache module provides handy procedural and object oriented interface to memcached, highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications.&lt;br /&gt;&lt;br /&gt;The Memcache module also provides a session handler (memcache).&lt;br /&gt;&lt;br /&gt;More information about memcached can be found at » http://www.danga.com/memcached/.&lt;br /&gt;&lt;br /&gt;Below is one example&lt;br /&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;$memcache = new Memcache;&lt;br /&gt;$memcache-&gt;connect('localhost', 11211) or die ("Could not connect");&lt;br /&gt;&lt;br /&gt;$version = $memcache-&gt;getVersion();&lt;br /&gt;echo "Server's version: ".$version."&lt;br/&gt;\n";&lt;br /&gt;&lt;br /&gt;$tmp_object = new stdClass;&lt;br /&gt;$tmp_object-&gt;str_attr = 'test';&lt;br /&gt;$tmp_object-&gt;int_attr = 123;&lt;br /&gt;&lt;br /&gt;$memcache-&gt;set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");&lt;br /&gt;echo "Store data in the cache (data will expire in 10 seconds)&lt;br/&gt;\n";&lt;br /&gt;&lt;br /&gt;$get_result = $memcache-&gt;get('key');&lt;br /&gt;echo "Data from the cache:&lt;br/&gt;\n";&lt;br /&gt;&lt;br /&gt;var_dump($get_result);&lt;br /&gt;&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-2275600408986693965?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/11/memcache.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-3883789768568875762</guid><pubDate>Sat, 31 May 2008 04:40:00 +0000</pubDate><atom:updated>2008-05-30T21:42:39.058-07:00</atom:updated><title>PHP Design Patterns</title><description>Patterns are ways to describe best practices and good designs. They show a flexible solution to common programming problems.&lt;br /&gt;&lt;br /&gt;    * Factory Patterns:     The Factory pattern allows for the instantiation of objects at runtime. It is called a Factory Pattern since it is responsible for "manufacturing" an object. A Parameterized Factory receives the name of the class to instantiate as argument.&lt;br /&gt;&lt;br /&gt;    * Singleton Patterns:     The Singleton pattern applies to situations in which there needs to be a single instance of a class. The most common example of this is a database connection. Implementing this pattern allows a programmer to make this single instance easily accessible by many other objects.&lt;br /&gt; i got this good stuff from a newly coming website on PHP, http://www.e-php.info&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-3883789768568875762?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/05/php-design-patterns.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-4891618596734335389</guid><pubDate>Sun, 25 May 2008 05:30:00 +0000</pubDate><atom:updated>2008-05-24T22:33:23.417-07:00</atom:updated><title>metaphone — Calculate the metaphone key of a string</title><description>Description&lt;br /&gt;string metaphone ( string $str [, int $phones ] )&lt;br /&gt;&lt;br /&gt;Calculates the metaphone key of str .&lt;br /&gt;&lt;br /&gt;Similar to soundex() metaphone creates the same key for similar sounding words. It's more accurate than soundex() as it knows the basic rules of English pronunciation. The metaphone generated keys are of variable length.&lt;br /&gt;&lt;br /&gt;Metaphone was developed by Lawrence Philips &lt;lphilips at verity dot com&gt;. It is described in ["Practical Algorithms for Programmers", Binstock &amp; Rex, Addison Wesley, 1995].&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-4891618596734335389?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/05/metaphone-calculate-metaphone-key-of.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>1</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-8118392546920994059</guid><pubDate>Sun, 25 May 2008 05:24:00 +0000</pubDate><atom:updated>2008-05-24T22:29:11.675-07:00</atom:updated><title>quotemeta — Quote meta characters</title><description>&lt;div class="refsect1 description"&gt;   &lt;h3 class="title"&gt;Description&lt;/h3&gt;   &lt;div class="methodsynopsis dc-description"&gt;    &lt;span class="type"&gt;string&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;quotemeta&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ( &lt;span class="methodparam"&gt;&lt;span class="type"&gt;string&lt;/span&gt; &lt;tt class="parameter"&gt;$str&lt;/tt&gt;&lt;/span&gt;    )&lt;/div&gt;    &lt;p class="para rdfs-comment"&gt;    Returns a version of str with a backslash character (&lt;i&gt;\&lt;/i&gt;)    before every character that is among these:     &lt;/p&gt;&lt;div class="example-contents"&gt;&lt;pre&gt;. \ + * ? [ ^ ] ( $ )&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  Returns the string with meta characters quoted.&lt;br /&gt;&lt;span class="simpara"&gt;This function is&lt;br /&gt;binary-safe.&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;     &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-8118392546920994059?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/05/quotemeta-quote-meta-characters.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-21014531649365938</guid><pubDate>Sun, 25 May 2008 05:10:00 +0000</pubDate><atom:updated>2008-05-24T22:11:53.859-07:00</atom:updated><title>parse_str — Parses the string into variables</title><description>&lt;div class="example-contents"&gt; &lt;div class="phpcode"&gt;&lt;dl&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;str&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;       &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        The input string.       &lt;/p&gt;      &lt;/dd&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;arr&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;       &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        If the second parameter &lt;i&gt;&lt;tt class="parameter"&gt;arr&lt;/tt&gt;&lt;/i&gt;  is present,        variables are stored in this variable as array elements instead.       &lt;/p&gt;      &lt;/dd&gt;&lt;/dl&gt;&lt;br /&gt;&lt;span class="type"&gt;&lt;span class="type void"&gt;&lt;br /&gt;void&lt;/span&gt;&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;parse_str&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ( &lt;span class="methodparam"&gt;&lt;span class="type"&gt;string&lt;/span&gt; &lt;tt class="parameter"&gt;$str&lt;/tt&gt;&lt;/span&gt;    [, &lt;span class="methodparam"&gt;&lt;span class="type"&gt;array&lt;/span&gt; &lt;tt class="parameter reference"&gt;&amp;amp;$arr&lt;/tt&gt;&lt;/span&gt;   ] )&lt;br /&gt;&lt;br /&gt;   No value is returned.&lt;br /&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;&lt;?php&lt;br /&gt;$str &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"first=value&amp;amp;arr[]=foo+bar&amp;amp;arr[]=baz"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;parse_str&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$str&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;echo &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$first&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;  &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// value&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;echo &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$arr&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;]; &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// foo bar&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;echo &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$arr&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;]; &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// baz&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;parse_str&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$str&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$output&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;echo &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$output&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'first'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;];  &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// value&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;echo &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$output&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'arr'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;][&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;0&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;]; &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// foo bar&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;echo &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$output&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'arr'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;][&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;]; &lt;/span&gt;&lt;span style="color: rgb(255, 128, 0);"&gt;// baz&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;?&gt;&lt;/span&gt; &lt;/span&gt; &lt;/code&gt;&lt;/div&gt;     &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-21014531649365938?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/05/parsestr-parses-string-into-variables.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-3045394629005339773</guid><pubDate>Sun, 25 May 2008 05:04:00 +0000</pubDate><atom:updated>2008-05-24T22:09:11.484-07:00</atom:updated><title>sha1 — Calculate the sha1 hash of a string</title><description>&lt;div class="example-contents"&gt;&lt;span class="type"&gt;string&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;sha1&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ( &lt;span class="methodparam"&gt;&lt;span class="type"&gt;string&lt;/span&gt; &lt;tt class="parameter"&gt;$str&lt;/tt&gt;&lt;/span&gt;    [, &lt;span class="methodparam"&gt;&lt;span class="type"&gt;bool&lt;/span&gt; &lt;tt class="parameter"&gt;$raw_output&lt;/tt&gt;&lt;/span&gt;   ] )&lt;br /&gt;   Returns the sha1 hash as a string.&lt;br /&gt;&lt;div class="phpcode"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(0, 0, 187);"&gt;&lt;?php&lt;br /&gt;$str &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'apple'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;&lt;br /&gt;if (&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;sha1&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$str&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;) === &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'d0be2dc421be4fcd0172e5afceea3970e2f3d940'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;) {&lt;br /&gt;    echo &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"Would you like a green or red apple?"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;    exit;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;?&gt;&lt;/span&gt; &lt;/span&gt; &lt;/code&gt;&lt;/div&gt;     &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-3045394629005339773?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/05/sha1-calculate-sha1-hash-of-string.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-1970081864412527184</guid><pubDate>Thu, 21 Feb 2008 17:29:00 +0000</pubDate><atom:updated>2008-02-21T09:30:14.844-08:00</atom:updated><title>array_values — Return all the values of an array</title><description>&lt;h3 class="title"&gt;Description&lt;/h3&gt;   &lt;div class="methodsynopsis"&gt;    &lt;span class="type"&gt;array&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;array_values&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ( &lt;span class="methodparam"&gt;&lt;span class="type"&gt;array&lt;/span&gt; &lt;tt class="parameter"&gt;$input&lt;/tt&gt;&lt;/span&gt;    )&lt;/div&gt;    &lt;p class="para"&gt;    &lt;b&gt;array_values()&lt;/b&gt; returns all the values from the    &lt;i&gt;&lt;tt class="parameter"&gt;input&lt;/tt&gt;&lt;/i&gt;  array and indexes numerically the    array.   &lt;/p&gt;   &lt;p class="para"&gt;    &lt;/p&gt;&lt;div class="example"&gt;     &lt;p&gt;&lt;b&gt;Example#1 &lt;b&gt;array_values()&lt;/b&gt; example&lt;/b&gt;&lt;/p&gt;     &lt;div class="example-contents"&gt; &lt;div class="phpcode"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(0, 0, 187);"&gt;&lt;?php&lt;br /&gt;$array &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= array(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"size" &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&gt; &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"XL"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"color" &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&gt; &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"gold"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;print_r&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;array_values&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$array&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;));&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;?&gt;&lt;/span&gt; &lt;/span&gt; &lt;/code&gt;&lt;/div&gt;     &lt;/div&gt;      &lt;div class="example-contents"&gt;&lt;p&gt;The above example will output:&lt;/p&gt;&lt;/div&gt;     &lt;div class="example-contents"&gt;&lt;pre&gt;&lt;div class="cdata"&gt;&lt;pre&gt;Array&lt;br /&gt;(&lt;br /&gt;   [0] =&gt; XL&lt;br /&gt;   [1] =&gt; gold&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;   &lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-1970081864412527184?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/02/arrayvalues-return-all-values-of-array.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-8314675696565708246</guid><pubDate>Thu, 21 Feb 2008 17:29:00 +0000</pubDate><atom:updated>2008-02-21T09:29:34.823-08:00</atom:updated><title>array_flip — Exchanges all keys with their associated values in an array</title><description>&lt;div class="refsect1 description"&gt;   &lt;h3 class="title"&gt;Description&lt;/h3&gt;   &lt;div class="methodsynopsis"&gt;    &lt;span class="type"&gt;array&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;array_flip&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ( &lt;span class="methodparam"&gt;&lt;span class="type"&gt;array&lt;/span&gt; &lt;tt class="parameter"&gt;$trans&lt;/tt&gt;&lt;/span&gt;    )&lt;/div&gt;    &lt;p class="para"&gt;    &lt;b&gt;array_flip()&lt;/b&gt; returns an &lt;a href="http://in.php.net/manual/en/language.types.array.php" class="type array"&gt;array&lt;/a&gt; in flip    order, i.e. keys from &lt;i&gt;&lt;tt class="parameter"&gt;trans&lt;/tt&gt;&lt;/i&gt;  become values and values    from &lt;i&gt;&lt;tt class="parameter"&gt;trans&lt;/tt&gt;&lt;/i&gt;  become keys.   &lt;/p&gt;   &lt;p class="para"&gt;    Note that the values of &lt;i&gt;&lt;tt class="parameter"&gt;trans&lt;/tt&gt;&lt;/i&gt;  need to be valid    keys, i.e. they need to be either &lt;a href="http://in.php.net/manual/en/language.types.integer.php" class="type integer"&gt;integer&lt;/a&gt; or    &lt;a href="http://in.php.net/manual/en/language.types.string.php" class="type string"&gt;string&lt;/a&gt;. A warning will be emitted if a value has the wrong    type, and the key/value pair in question &lt;em class="emphasis"&gt;will not be    flipped&lt;/em&gt;.   &lt;/p&gt;   &lt;p class="para"&gt;    If a value has several occurrences, the latest key will be    used as its values, and all others will be lost.   &lt;/p&gt;  &lt;/div&gt;    &lt;div class="refsect1 parameters"&gt;   &lt;h3 class="title"&gt;Parameters&lt;/h3&gt;   &lt;p class="para"&gt;    &lt;/p&gt;&lt;dl&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;trans&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;      &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        An array of key/value pairs to be flipped.       &lt;/p&gt;      &lt;/dd&gt;&lt;/dl&gt;      &lt;/div&gt;    &lt;div class="refsect1 returnvalues"&gt;   &lt;h3 class="title"&gt;Return Values&lt;/h3&gt;   &lt;p class="para"&gt;    Returns the flipped array on success and &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt; on failure.   &lt;/p&gt;  &lt;/div&gt;    &lt;div class="refsect1 examples"&gt;   &lt;h3 class="title"&gt;Examples&lt;/h3&gt;   &lt;p class="para"&gt;    &lt;/p&gt;&lt;div class="example"&gt;     &lt;p&gt;&lt;b&gt;Example#1 &lt;b&gt;array_flip()&lt;/b&gt; example&lt;/b&gt;&lt;/p&gt;     &lt;div class="example-contents"&gt; &lt;div class="phpcode"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(0, 0, 187);"&gt;&lt;?php&lt;br /&gt;$trans &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;array_flip&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$trans&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$original &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;strtr&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$str&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$trans&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;?&gt;&lt;/span&gt; &lt;/span&gt; &lt;/code&gt;&lt;/div&gt;     &lt;/div&gt;     &lt;/div&gt;      &lt;p class="para"&gt;    &lt;/p&gt;&lt;div class="example"&gt;     &lt;p&gt;&lt;b&gt;Example#2 &lt;b&gt;array_flip()&lt;/b&gt; example : collision&lt;/b&gt;&lt;/p&gt;     &lt;div class="example-contents"&gt; &lt;div class="phpcode"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(0, 0, 187);"&gt;&lt;?php&lt;br /&gt;$trans &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= array(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"a" &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"b" &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;1&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"c" &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&gt; &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;2&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$trans &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;array_flip&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$trans&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;print_r&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$trans&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;?&gt;&lt;/span&gt; &lt;/span&gt; &lt;/code&gt;&lt;/div&gt;     &lt;/div&gt;      &lt;div class="example-contents"&gt;&lt;p&gt;      now &lt;var class="varname"&gt;$trans&lt;/var&gt; is:     &lt;/p&gt;&lt;/div&gt;     &lt;div class="example-contents"&gt;&lt;pre&gt;&lt;div class="cdata"&gt;&lt;pre&gt;Array&lt;br /&gt;(&lt;br /&gt;   [1] =&gt; b&lt;br /&gt;   [2] =&gt; c&lt;br /&gt;)&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;   &lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;     &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-8314675696565708246?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/02/arrayflip-exchanges-all-keys-with-their.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-4315889389842874072</guid><pubDate>Thu, 21 Feb 2008 17:26:00 +0000</pubDate><atom:updated>2008-02-21T09:28:58.364-08:00</atom:updated><title>array_walk — Apply a user function to every member of an array</title><description>&lt;h3 class="title"&gt;Description&lt;/h3&gt;   &lt;div class="methodsynopsis"&gt;    &lt;span class="type"&gt;bool&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;array_walk&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ( &lt;span class="methodparam"&gt;&lt;span class="type"&gt;array&lt;/span&gt; &lt;tt class="parameter reference"&gt;&amp;amp;$array&lt;/tt&gt;&lt;/span&gt;    , &lt;span class="methodparam"&gt;&lt;span class="type"&gt;callback&lt;/span&gt; &lt;tt class="parameter"&gt;$funcname&lt;/tt&gt;&lt;/span&gt;    [, &lt;span class="methodparam"&gt;&lt;span class="type"&gt;mixed&lt;/span&gt; &lt;tt class="parameter"&gt;$userdata&lt;/tt&gt;&lt;/span&gt;   ] )&lt;/div&gt;    &lt;p class="simpara"&gt;    Returns &lt;b&gt;&lt;tt&gt;TRUE&lt;/tt&gt;&lt;/b&gt; on success or &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt; on failure.   &lt;/p&gt;   &lt;p class="simpara"&gt;    Applies the user-defined function &lt;i&gt;&lt;tt class="parameter"&gt;funcname&lt;/tt&gt;&lt;/i&gt;  to each    element of the &lt;i&gt;&lt;tt class="parameter"&gt;array&lt;/tt&gt;&lt;/i&gt;  array. Typically,    &lt;i&gt;&lt;tt class="parameter"&gt;funcname&lt;/tt&gt;&lt;/i&gt;  takes on two parameters.    The &lt;i&gt;&lt;tt class="parameter"&gt;array&lt;/tt&gt;&lt;/i&gt;  parameter's value being the first, and    the key/index second. If the optional &lt;i&gt;&lt;tt class="parameter"&gt;userdata&lt;/tt&gt;&lt;/i&gt;     parameter is supplied, it will be passed as the third parameter to    the callback &lt;i&gt;&lt;tt class="parameter"&gt;funcname&lt;/tt&gt;&lt;/i&gt; .   &lt;/p&gt;   &lt;p class="simpara"&gt;    If function &lt;i&gt;&lt;tt class="parameter"&gt;funcname&lt;/tt&gt;&lt;/i&gt;  requires more parameters than    given to it, an error of level &lt;a href="http://in.php.net/manual/en/ref.errorfunc.php#errorfunc.constants" class="link"&gt;    E_WARNING&lt;/a&gt; will be generated each time &lt;b&gt;array_walk()&lt;/b&gt;    calls &lt;i&gt;&lt;tt class="parameter"&gt;funcname&lt;/tt&gt;&lt;/i&gt; . These warnings may be suppressed by    prepending the PHP error operator    &lt;a href="http://in.php.net/manual/en/language.operators.errorcontrol.php" class="link"&gt;@&lt;/a&gt; to the    &lt;b&gt;array_walk()&lt;/b&gt; call, or by using    &lt;a href="http://in.php.net/manual/en/function.error-reporting.php" class="function"&gt;error_reporting()&lt;/a&gt;.   &lt;/p&gt;   &lt;blockquote&gt;&lt;p&gt;&lt;b class="note"&gt;Note&lt;/b&gt;:          If &lt;i&gt;&lt;tt class="parameter"&gt;funcname&lt;/tt&gt;&lt;/i&gt;  needs to be working with the     actual values of the array, specify the first parameter of     &lt;i&gt;&lt;tt class="parameter"&gt;funcname&lt;/tt&gt;&lt;/i&gt;  as a     &lt;a href="http://in.php.net/manual/en/language.references.php" class="link"&gt;reference&lt;/a&gt;. Then,     any changes made to those elements will be made in the     original array itself.   &lt;br /&gt;  &lt;/p&gt;&lt;/blockquote&gt;   &lt;blockquote&gt;&lt;p&gt;&lt;b class="note"&gt;Note&lt;/b&gt;:          Passing the key and userdata to &lt;i&gt;&lt;tt class="parameter"&gt;funcname&lt;/tt&gt;&lt;/i&gt;  was     added in 4.0.0   &lt;br /&gt;  &lt;/p&gt;&lt;/blockquote&gt;   &lt;p class="para"&gt;    &lt;b&gt;array_walk()&lt;/b&gt; is not affected by the internal    array pointer of &lt;i&gt;&lt;tt class="parameter"&gt;array&lt;/tt&gt;&lt;/i&gt; .  &lt;b&gt;    array_walk()&lt;/b&gt; will walk through the entire array    regardless of pointer position.   &lt;/p&gt;   &lt;p class="para"&gt;    Users may not change the array itself from the callback    function. e.g. Add/delete elements, unset elements, etc.  If    the array that &lt;b&gt;array_walk()&lt;/b&gt; is applied to    is changed, the behavior of this function is undefined, and    unpredictable.   &lt;/p&gt;   &lt;p class="para"&gt;    &lt;/p&gt;&lt;div class="example"&gt;     &lt;p&gt;&lt;b&gt;Example#1 &lt;b&gt;array_walk()&lt;/b&gt; example&lt;/b&gt;&lt;/p&gt;     &lt;div class="example-contents"&gt; &lt;div class="phpcode"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(0, 0, 187);"&gt;&lt;?php&lt;br /&gt;$fruits &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= array(&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"d" &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&gt; &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"lemon"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"a" &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&gt; &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"orange"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"b" &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&gt; &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"banana"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"c" &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;=&gt; &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"apple"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;br /&gt;function &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;test_alter&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&amp;amp;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$item1&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$key&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$prefix&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;{&lt;br /&gt;    &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$item1 &lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;= &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"$prefix: $item1"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;test_print&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$item2&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$key&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;)&lt;br /&gt;{&lt;br /&gt;    echo &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"$key. $item2&lt;br /&gt;\n"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;echo &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"Before ...:\n"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;array_walk&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$fruits&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'test_print'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;array_walk&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$fruits&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'test_alter'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'fruit'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;echo &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"... and after:\n"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;array_walk&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$fruits&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'test_print'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;?&gt;&lt;/span&gt; &lt;/span&gt; &lt;/code&gt;&lt;/div&gt;     &lt;/div&gt;      &lt;div class="example-contents"&gt;&lt;p&gt;The above example will output:&lt;/p&gt;&lt;/div&gt;     &lt;div class="example-contents"&gt;&lt;pre&gt;&lt;div class="cdata"&gt;&lt;pre&gt;Before ...:&lt;br /&gt;d. lemon&lt;br /&gt;a. orange&lt;br /&gt;b. banana&lt;br /&gt;c. apple&lt;br /&gt;... and after:&lt;br /&gt;d. fruit: lemon&lt;br /&gt;a. fruit: orange&lt;br /&gt;b. fruit: banana&lt;br /&gt;c. fruit: apple&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;   &lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-4315889389842874072?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/02/arraywalk-apply-user-function-to-every.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-7988674884962844484</guid><pubDate>Wed, 20 Feb 2008 17:38:00 +0000</pubDate><atom:updated>2008-02-20T09:39:05.386-08:00</atom:updated><title>readfile — Outputs a file</title><description>&lt;div class="refsect1 description"&gt;   &lt;h3 class="title"&gt;Description&lt;/h3&gt;   &lt;div class="methodsynopsis"&gt;    &lt;span class="type"&gt;int&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;readfile&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ( &lt;span class="methodparam"&gt;&lt;span class="type"&gt;string&lt;/span&gt; &lt;tt class="parameter"&gt;$filename&lt;/tt&gt;&lt;/span&gt;    [, &lt;span class="methodparam"&gt;&lt;span class="type"&gt;bool&lt;/span&gt; &lt;tt class="parameter"&gt;$use_include_path&lt;/tt&gt;&lt;/span&gt;    [, &lt;span class="methodparam"&gt;&lt;span class="type"&gt;resource&lt;/span&gt; &lt;tt class="parameter"&gt;$context&lt;/tt&gt;&lt;/span&gt;   ]] )&lt;/div&gt;    &lt;p class="para"&gt;    Reads a file and writes it to the output buffer.   &lt;/p&gt;  &lt;/div&gt;    &lt;div class="refsect1 parameters"&gt;   &lt;h3 class="title"&gt;Parameters&lt;/h3&gt;   &lt;p class="para"&gt;    &lt;/p&gt;&lt;dl&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;filename&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;      &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        The filename being read.       &lt;/p&gt;      &lt;/dd&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;use_include_path&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;      &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        You can use the optional second parameter and set it to &lt;b&gt;&lt;tt&gt;TRUE&lt;/tt&gt;&lt;/b&gt;, if        you want to search for the file in the &lt;a href="http://in2.php.net/manual/en/ini.core.php#ini.include-path" class="link"&gt;include_path&lt;/a&gt;, too.       &lt;/p&gt;      &lt;/dd&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;context&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;      &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        A context stream &lt;a href="http://in2.php.net/manual/en/language.types.resource.php" class="type resource"&gt;resource&lt;/a&gt;.       &lt;/p&gt;      &lt;/dd&gt;&lt;/dl&gt;      &lt;/div&gt;     &lt;div class="refsect1 returnvalues"&gt;   &lt;h3 class="title"&gt;Return Values&lt;/h3&gt;   &lt;p class="para"&gt;    Returns the number of bytes read from the file. If an error    occurs, &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt; is returned and unless the function was called as    @&lt;b&gt;readfile()&lt;/b&gt;, an error message is printed.   &lt;/p&gt; &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;span class="html"&gt;&lt;span class="default"&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;session_cache_limiter&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="string"&gt;'none'&lt;/span&gt;&lt;span class="keyword"&gt;); &lt;/span&gt;&lt;span class="comment"&gt;//*Use before session_start()&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;session_start&lt;/span&gt;&lt;span class="keyword"&gt;();&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;$file &lt;/span&gt;&lt;span class="keyword"&gt;= &lt;/span&gt;&lt;span class="string"&gt;'ASDFGgg.pdf'&lt;/span&gt;&lt;span class="keyword"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;_Download&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="string"&gt;"files_dir/"&lt;/span&gt;&lt;span class="keyword"&gt;.&lt;/span&gt;&lt;span class="default"&gt;$file&lt;/span&gt;&lt;span class="keyword"&gt;, &lt;/span&gt;&lt;span class="default"&gt;$file&lt;/span&gt;&lt;span class="keyword"&gt;);&lt;br /&gt;&lt;br /&gt;function &lt;/span&gt;&lt;span class="default"&gt;_Download&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$f_location&lt;/span&gt;&lt;span class="keyword"&gt;,&lt;/span&gt;&lt;span class="default"&gt;$f_name&lt;/span&gt;&lt;span class="keyword"&gt;){&lt;br /&gt;     &lt;/span&gt;&lt;span class="default"&gt;header &lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="string"&gt;"Cache-Control: must-revalidate, post-check=0, pre-check=0"&lt;/span&gt;&lt;span class="keyword"&gt;);&lt;br /&gt;    &lt;/span&gt;&lt;span class="default"&gt;header&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="string"&gt;'Content-Description: File Transfer'&lt;/span&gt;&lt;span class="keyword"&gt;);&lt;br /&gt;    &lt;/span&gt;&lt;span class="default"&gt;header&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="string"&gt;'Content-Type: application/octet-stream'&lt;/span&gt;&lt;span class="keyword"&gt;);&lt;br /&gt;    &lt;/span&gt;&lt;span class="default"&gt;header&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="string"&gt;'Content-Length: ' &lt;/span&gt;&lt;span class="keyword"&gt;. &lt;/span&gt;&lt;span class="default"&gt;filesize&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$f_location&lt;/span&gt;&lt;span class="keyword"&gt;));&lt;br /&gt;    &lt;/span&gt;&lt;span class="default"&gt;header&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="string"&gt;'Content-Disposition: attachment; filename=' &lt;/span&gt;&lt;span class="keyword"&gt;. &lt;/span&gt;&lt;span class="default"&gt;basename&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$f_name&lt;/span&gt;&lt;span class="keyword"&gt;));&lt;br /&gt;    &lt;/span&gt;&lt;span class="default"&gt;readfile&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$f_location&lt;/span&gt;&lt;span class="keyword"&gt;);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;?&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-7988674884962844484?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/02/readfile-outputs-file.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-3593741623135596857</guid><pubDate>Wed, 20 Feb 2008 17:37:00 +0000</pubDate><atom:updated>2008-02-20T09:38:19.514-08:00</atom:updated><title>is_uploaded_file — Tells whether the file was uploaded via HTTP POST</title><description>&lt;div class="refsect1 description"&gt;   &lt;h3 class="title"&gt;Description&lt;/h3&gt;   &lt;div class="methodsynopsis"&gt;    &lt;span class="type"&gt;bool&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;is_uploaded_file&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ( &lt;span class="methodparam"&gt;&lt;span class="type"&gt;string&lt;/span&gt; &lt;tt class="parameter"&gt;$filename&lt;/tt&gt;&lt;/span&gt;    )&lt;/div&gt;    &lt;p class="para"&gt;    Returns &lt;b&gt;&lt;tt&gt;TRUE&lt;/tt&gt;&lt;/b&gt; if the file named by &lt;i&gt;&lt;tt class="parameter"&gt;filename&lt;/tt&gt;&lt;/i&gt;  was    uploaded via HTTP POST. This is useful to help ensure that a    malicious user hasn't tried to trick the script into working on    files upon which it should not be working--for instance,    &lt;var class="filename"&gt;/etc/passwd&lt;/var&gt;.   &lt;/p&gt;   &lt;p class="para"&gt;    This sort of check is especially important if there is any chance    that anything done with uploaded files could reveal their    contents to the user, or even to other users on the same    system.   &lt;/p&gt;   &lt;p class="para"&gt;    For proper working, the function &lt;b&gt;is_uploaded_file()&lt;/b&gt; needs    an argument like $_FILES['userfile']['tmp_name'], - the name of the uploaded    file on the clients machine $_FILES['userfile']['name'] does not work.   &lt;/p&gt;  &lt;/div&gt;    &lt;div class="refsect1 parameters"&gt;   &lt;h3 class="title"&gt;Parameters&lt;/h3&gt;   &lt;p class="para"&gt;    &lt;/p&gt;&lt;dl&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;filename&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;      &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        The filename being checked.       &lt;/p&gt;      &lt;/dd&gt;&lt;/dl&gt;      &lt;/div&gt;    &lt;div class="refsect1 returnvalues"&gt;   &lt;h3 class="title"&gt;Return Values&lt;/h3&gt;   &lt;p class="para"&gt;    Returns &lt;b&gt;&lt;tt&gt;TRUE&lt;/tt&gt;&lt;/b&gt; on success or &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt; on failure.   &lt;/p&gt; &lt;br /&gt;&lt;div class="example-contents"&gt; &lt;div class="phpcode"&gt;&lt;code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; &lt;span style="color: rgb(0, 0, 187);"&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;if (&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;is_uploaded_file&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_FILES&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'userfile'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;][&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'tmp_name'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;])) {&lt;br /&gt;   echo &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"File "&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;. &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_FILES&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'userfile'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;][&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'name'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;] .&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;" uploaded successfully.\n"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;   echo &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"Displaying contents\n"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;   &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;readfile&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;(&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_FILES&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'userfile'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;][&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'tmp_name'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;]);&lt;br /&gt;} else {&lt;br /&gt;   echo &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"Possible file upload attack: "&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;   echo &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"filename '"&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;. &lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;$_FILES&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;[&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'userfile'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;][&lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;'tmp_name'&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;] . &lt;/span&gt;&lt;span style="color: rgb(221, 0, 0);"&gt;"'."&lt;/span&gt;&lt;span style="color: rgb(0, 119, 0);"&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 187);"&gt;?&gt;&lt;/span&gt; &lt;/span&gt; &lt;/code&gt;&lt;/div&gt;     &lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-3593741623135596857?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/02/isuploadedfile-tells-whether-file-was.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-2218734352007959444</guid><pubDate>Wed, 20 Feb 2008 17:36:00 +0000</pubDate><atom:updated>2008-02-20T09:37:26.217-08:00</atom:updated><title>move_uploaded_file — Moves an uploaded file to a new location</title><description>&lt;div class="refsect1 description"&gt;   &lt;h3 class="title"&gt;Description&lt;/h3&gt;   &lt;div class="methodsynopsis"&gt;    &lt;span class="type"&gt;bool&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;move_uploaded_file&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ( &lt;span class="methodparam"&gt;&lt;span class="type"&gt;string&lt;/span&gt; &lt;tt class="parameter"&gt;$filename&lt;/tt&gt;&lt;/span&gt;    , &lt;span class="methodparam"&gt;&lt;span class="type"&gt;string&lt;/span&gt; &lt;tt class="parameter"&gt;$destination&lt;/tt&gt;&lt;/span&gt;    )&lt;/div&gt;    &lt;p class="para"&gt;    This function checks to ensure that the file designated by    &lt;i&gt;&lt;tt class="parameter"&gt;filename&lt;/tt&gt;&lt;/i&gt;  is a valid upload file (meaning    that it was uploaded via PHP's HTTP POST upload mechanism). If    the file is valid, it will be moved to the filename given by    &lt;i&gt;&lt;tt class="parameter"&gt;destination&lt;/tt&gt;&lt;/i&gt; .   &lt;/p&gt;   &lt;p class="para"&gt;    This sort of check is especially important if there is any chance    that anything done with uploaded files could reveal their    contents to the user, or even to other users on the same    system.   &lt;/p&gt;  &lt;/div&gt;    &lt;div class="refsect1 parameters"&gt;   &lt;h3 class="title"&gt;Parameters&lt;/h3&gt;   &lt;p class="para"&gt;    &lt;/p&gt;&lt;dl&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;filename&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;      &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        The filename of the uploaded file.       &lt;/p&gt;      &lt;/dd&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;destination&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;      &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        The destination of the moved file.       &lt;/p&gt;      &lt;/dd&gt;&lt;/dl&gt;      &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-2218734352007959444?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/02/moveuploadedfile-moves-uploaded-file-to.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-1936689136527171793</guid><pubDate>Wed, 20 Feb 2008 17:34:00 +0000</pubDate><atom:updated>2008-02-20T09:35:29.138-08:00</atom:updated><title>ob_end_flush — Flush (send) the output buffer and turn off output buffering</title><description>&lt;div class="refsect1 description"&gt;   &lt;h3 class="title"&gt;Description&lt;/h3&gt;   &lt;div class="methodsynopsis"&gt;    &lt;span class="type"&gt;bool&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;ob_end_flush&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ( &lt;span class="methodparam"&gt;void&lt;/span&gt;    )&lt;/div&gt;    &lt;p class="para"&gt;    This function will send the contents of the topmost output buffer (if    any) and turn this output buffer off.  If you want to further    process the buffer's contents you have to call    &lt;a href="http://in2.php.net/manual/en/function.ob-get-contents.php" class="function"&gt;ob_get_contents()&lt;/a&gt; before    &lt;b&gt;ob_end_flush()&lt;/b&gt; as the buffer contents are    discarded after &lt;b&gt;ob_end_flush()&lt;/b&gt; is called.   &lt;/p&gt;   &lt;blockquote&gt;&lt;p&gt;&lt;b class="note"&gt;Note&lt;/b&gt;:     &lt;span class="simpara"&gt;     This function is similar to &lt;a href="http://in2.php.net/manual/en/function.ob-get-flush.php" class="function"&gt;ob_get_flush()&lt;/a&gt;, except     that &lt;a href="http://in2.php.net/manual/en/function.ob-get-flush.php" class="function"&gt;ob_get_flush()&lt;/a&gt; returns the buffer as a string.    &lt;/span&gt;   &lt;/p&gt;&lt;/blockquote&gt;  &lt;/div&gt;    &lt;div class="refsect1 returnvalues"&gt;   &lt;h3 class="title"&gt;Return Values&lt;/h3&gt;   &lt;p class="para"&gt;    Returns &lt;b&gt;&lt;tt&gt;TRUE&lt;/tt&gt;&lt;/b&gt; on success or &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt; on failure. Reasons for failure are first that you called the    function without an active buffer or that for some reason a buffer could    not be deleted (possible for special buffer).   &lt;/p&gt;  &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-1936689136527171793?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/02/obendflush-flush-send-output-buffer-and.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-755430606441627649</guid><pubDate>Wed, 20 Feb 2008 17:32:00 +0000</pubDate><atom:updated>2008-02-20T09:34:12.616-08:00</atom:updated><title>ob_start — Turn on output buffering</title><description>&lt;div class="refsect1 description"&gt;   &lt;h3 class="title"&gt;Description&lt;/h3&gt;   &lt;div class="methodsynopsis"&gt;    &lt;span class="type"&gt;bool&lt;/span&gt; &lt;span class="methodname"&gt;&lt;b&gt;&lt;b&gt;ob_start&lt;/b&gt;&lt;/b&gt;&lt;/span&gt;     ([ &lt;span class="methodparam"&gt;&lt;span class="type"&gt;callback&lt;/span&gt; &lt;tt class="parameter"&gt;$output_callback&lt;/tt&gt;&lt;/span&gt;    [, &lt;span class="methodparam"&gt;&lt;span class="type"&gt;int&lt;/span&gt; &lt;tt class="parameter"&gt;$chunk_size&lt;/tt&gt;&lt;/span&gt;    [, &lt;span class="methodparam"&gt;&lt;span class="type"&gt;bool&lt;/span&gt; &lt;tt class="parameter"&gt;$erase&lt;/tt&gt;&lt;/span&gt;   ]]] )&lt;/div&gt;    &lt;p class="para"&gt;    This function will turn output buffering on. While output buffering is    active no output is sent from the script (other than headers), instead the    output is stored in an internal buffer.   &lt;/p&gt;   &lt;p class="para"&gt;    The contents of this internal buffer may be copied into a string variable    using &lt;a href="http://in2.php.net/manual/en/function.ob-get-contents.php" class="function"&gt;ob_get_contents()&lt;/a&gt;.  To output what is stored in    the internal buffer, use &lt;a href="http://in2.php.net/manual/en/function.ob-end-flush.php" class="function"&gt;ob_end_flush()&lt;/a&gt;. Alternatively,    &lt;a href="http://in2.php.net/manual/en/function.ob-end-clean.php" class="function"&gt;ob_end_clean()&lt;/a&gt; will silently discard the buffer    contents.   &lt;/p&gt;   &lt;div class="warning"&gt;&lt;b class="warning"&gt;Warning&lt;/b&gt;    &lt;p class="para"&gt;     Some web servers (e.g. Apache) change the working directory of a script     when calling the callback function. You can change it back by e.g.     &lt;i class="literal"&gt;chdir(dirname($_SERVER['SCRIPT_FILENAME']))&lt;/i&gt; in the     callback function.    &lt;/p&gt;   &lt;/div&gt;   &lt;p class="para"&gt;    Output buffers are stackable, that is, you may call    &lt;b&gt;ob_start()&lt;/b&gt; while another    &lt;b&gt;ob_start()&lt;/b&gt; is active. Just make    sure that you call &lt;a href="http://in2.php.net/manual/en/function.ob-end-flush.php" class="function"&gt;ob_end_flush()&lt;/a&gt;    the appropriate number of times. If multiple output callback    functions are active, output is being filtered sequentially    through each of them in nesting order.   &lt;/p&gt;  &lt;/div&gt;       &lt;h3 class="title"&gt;Parameters&lt;/h3&gt;   &lt;p class="para"&gt;    &lt;/p&gt;&lt;dl&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;output_callback&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;      &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        An optional &lt;i&gt;&lt;tt class="parameter"&gt;output_callback&lt;/tt&gt;&lt;/i&gt;  function may be        specified. This function takes a string as a parameter and should        return a string. The function will be called when        &lt;a href="http://in2.php.net/manual/en/function.ob-end-flush.php" class="function"&gt;ob_end_flush()&lt;/a&gt; is called, or when the output buffer        is flushed to the browser at the end of the request.  When        &lt;i&gt;&lt;tt class="parameter"&gt;output_callback&lt;/tt&gt;&lt;/i&gt;  is called, it will receive the        contents of the output buffer as its parameter and is expected to        return a new output buffer as a result, which will be sent to the        browser. If the &lt;i&gt;&lt;tt class="parameter"&gt;output_callback&lt;/tt&gt;&lt;/i&gt;  is not a        callable function, this function will return &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt;.       &lt;/p&gt;       &lt;p class="para"&gt;        If the callback function has two parameters, the second parameter is        filled with a bit-field consisting of        &lt;b&gt;&lt;tt&gt;PHP_OUTPUT_HANDLER_START&lt;/tt&gt;&lt;/b&gt;,        &lt;b&gt;&lt;tt&gt;PHP_OUTPUT_HANDLER_CONT&lt;/tt&gt;&lt;/b&gt; and        &lt;b&gt;&lt;tt&gt;PHP_OUTPUT_HANDLER_END&lt;/tt&gt;&lt;/b&gt;.       &lt;/p&gt;       &lt;p class="para"&gt;        If &lt;i&gt;&lt;tt class="parameter"&gt;output_callback&lt;/tt&gt;&lt;/i&gt;  returns &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt; original        input is sent to the browser.       &lt;/p&gt;       &lt;p class="para"&gt;        The &lt;i&gt;&lt;tt class="parameter"&gt;output_callback&lt;/tt&gt;&lt;/i&gt;  parameter may be bypassed        by passing a &lt;b&gt;&lt;tt&gt;NULL&lt;/tt&gt;&lt;/b&gt; value.       &lt;/p&gt;       &lt;p class="para"&gt;        &lt;a href="http://in2.php.net/manual/en/function.ob-end-clean.php" class="function"&gt;ob_end_clean()&lt;/a&gt;, &lt;a href="http://in2.php.net/manual/en/function.ob-end-flush.php" class="function"&gt;ob_end_flush()&lt;/a&gt;,        &lt;a href="http://in2.php.net/manual/en/function.ob-clean.php" class="function"&gt;ob_clean()&lt;/a&gt;, &lt;a href="http://in2.php.net/manual/en/function.ob-flush.php" class="function"&gt;ob_flush()&lt;/a&gt; and        &lt;b&gt;ob_start()&lt;/b&gt; may not be called from a callback        function. If you call them from callback function, the behavior is        undefined. If you would like to delete the contents of a buffer,        return "" (a null string) from callback function.        You can't even call functions using the output buffering functions like        &lt;i class="literal"&gt;print_r($expression, true)&lt;/i&gt; or        &lt;i class="literal"&gt;highlight_file($filename, true)&lt;/i&gt; from a callback        function.       &lt;/p&gt;       &lt;blockquote&gt;&lt;p&gt;&lt;b class="note"&gt;Note&lt;/b&gt;:                  In PHP 4.0.4, &lt;a href="http://in2.php.net/manual/en/function.ob-gzhandler.php" class="function"&gt;ob_gzhandler()&lt;/a&gt; was introduced to         facilitate sending gz-encoded data to web browsers that support         compressed web pages.  &lt;a href="http://in2.php.net/manual/en/function.ob-gzhandler.php" class="function"&gt;ob_gzhandler()&lt;/a&gt; determines         what type of content encoding the browser will accept and will return         its output accordingly.       &lt;br /&gt;      &lt;/p&gt;&lt;/blockquote&gt;      &lt;/dd&gt;&lt;dt&gt;       &lt;span class="term"&gt;&lt;i&gt;&lt;tt class="parameter"&gt;chunk_size&lt;/tt&gt;&lt;/i&gt; &lt;/span&gt;      &lt;/dt&gt;&lt;dd&gt;        &lt;p class="para"&gt;        If the optional parameter &lt;i&gt;&lt;tt class="parameter"&gt;chunk_size&lt;/tt&gt;&lt;/i&gt;  is passed, the        buffer will be flushed after any output call which causes the buffer's        length to equal or exceed &lt;i&gt;&lt;tt class="parameter"&gt;chunk_size&lt;/tt&gt;&lt;/i&gt; .        Default value 0 means that the function is called only in the end,        other special value 1 sets &lt;i&gt;&lt;tt class="parameter"&gt;chunk_size&lt;/tt&gt;&lt;/i&gt;  to 4096.       &lt;/p&gt;      &lt;/dd&gt;&lt;/dl&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-755430606441627649?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/02/obstart-turn-on-output-buffering.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-5753834897563424450</guid><pubDate>Tue, 19 Feb 2008 17:07:00 +0000</pubDate><atom:updated>2008-02-19T09:10:15.640-08:00</atom:updated><title>md5 — Calculate the md5 hash of a string</title><description>Calculates the MD5 hash of str using the &lt;a class="link external" href="http://www.faqs.org/rfcs/rfc1321"&gt;» RSA Data Security, Inc. MD5 Message-Digest Algorithm&lt;/a&gt;, and returns that hash.&lt;br /&gt;&lt;?php$str = 'apple';&lt;br /&gt;if ((md5($str) === '1f3870be274f6c49b3e31a0c6728957f') {  &lt;br /&gt; echo "Would you like a green or red apple?";    exit;}&lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-5753834897563424450?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2008/02/md5-calculate-md5-hash-of-string.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-386391598958563477</guid><pubDate>Thu, 25 Oct 2007 01:37:00 +0000</pubDate><atom:updated>2007-10-24T18:37:45.180-07:00</atom:updated><title>serialize — Generates a storable representation of a value</title><description>string &lt;b&gt;serialize&lt;/b&gt; ( mixed $value )&lt;br /&gt;&lt;p&gt;    Generates a storable representation of a value   &lt;/p&gt;&lt;p&gt;    This is useful for storing or passing PHP values around without    losing their type and structure.   &lt;/p&gt;&lt;p&gt;    To make the serialized string into a PHP value again, use    &lt;a href="http://in2.php.net/manual/en/function.unserialize.php"&gt;unserialize()&lt;/a&gt;.     &lt;/p&gt;&lt;h2&gt;Parameters&lt;/h2&gt;&lt;p&gt;    &lt;/p&gt;&lt;div class="variablelist"&gt;&lt;dl&gt;&lt;dt&gt;&lt;span class="term"&gt;&lt;i&gt;&lt;tt&gt;value&lt;/tt&gt;&lt;/i&gt;&lt;/span&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;        The value to be serialized. &lt;b&gt;serialize()&lt;/b&gt;        handles all types, except the &lt;a href="http://in2.php.net/manual/en/language.types.resource.php"&gt;resource&lt;/a&gt;-type.        You can even &lt;b&gt;serialize()&lt;/b&gt; arrays that contain        references to itself. Circular references inside the array/object you         are &lt;b&gt;serialize()&lt;/b&gt;ing will also be stored. Any other         reference will be lost.       &lt;/p&gt;&lt;p&gt;        When serializing objects, PHP will attempt to call the member function        &lt;b&gt;__sleep()&lt;/b&gt; prior to serialization. This is to allow the        object to do any last minute clean-up, etc. prior to being serialized.        Likewise, when the object is restored using &lt;a href="http://in2.php.net/manual/en/function.unserialize.php"&gt;unserialize()&lt;/a&gt;        the &lt;b&gt;__wakeup()&lt;/b&gt; member function is called.       &lt;/p&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;/div&gt;   &lt;h2&gt;Return Values&lt;/h2&gt;&lt;p&gt;    Returns a string containing a byte-stream representation of     &lt;i&gt;&lt;tt&gt;value&lt;/tt&gt;&lt;/i&gt; that can be stored anywhere.   &lt;/p&gt;&lt;h2&gt;Examples&lt;/h2&gt;&lt;p&gt;    &lt;/p&gt;&lt;div class="example"&gt;&lt;a name="id3750055"&gt;&lt;/a&gt;&lt;p&gt;&lt;b&gt;Example 2594. &lt;b&gt;serialize()&lt;/b&gt; example&lt;/b&gt;&lt;/p&gt;&lt;div class="example-contents"&gt; &lt;div class="phpcode"&gt;&lt;code&gt;&lt;span class="html"&gt; &lt;span class="default"&gt;&lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span class="comment"&gt;// $session_data contains a multi-dimensional array with session&lt;br /&gt;// information for the current user.  We use serialize() to store&lt;br /&gt;// it in a database at the end of the request.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;$conn &lt;/span&gt;&lt;span class="keyword"&gt;= &lt;/span&gt;&lt;span class="default"&gt;odbc_connect&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="string"&gt;"webdb"&lt;/span&gt;&lt;span class="keyword"&gt;, &lt;/span&gt;&lt;span class="string"&gt;"php"&lt;/span&gt;&lt;span class="keyword"&gt;, &lt;/span&gt;&lt;span class="string"&gt;"chicken"&lt;/span&gt;&lt;span class="keyword"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;$stmt &lt;/span&gt;&lt;span class="keyword"&gt;= &lt;/span&gt;&lt;span class="default"&gt;odbc_prepare&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$conn&lt;/span&gt;&lt;span class="keyword"&gt;,&lt;br /&gt;      &lt;/span&gt;&lt;span class="string"&gt;"UPDATE sessions SET data = ? WHERE id = ?"&lt;/span&gt;&lt;span class="keyword"&gt;);&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;$sqldata &lt;/span&gt;&lt;span class="keyword"&gt;= array (&lt;/span&gt;&lt;span class="default"&gt;serialize&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$session_data&lt;/span&gt;&lt;span class="keyword"&gt;), &lt;/span&gt;&lt;span class="default"&gt;$_SERVER&lt;/span&gt;&lt;span class="keyword"&gt;[&lt;/span&gt;&lt;span class="string"&gt;'PHP_AUTH_USER'&lt;/span&gt;&lt;span class="keyword"&gt;]);&lt;br /&gt;if (!&lt;/span&gt;&lt;span class="default"&gt;odbc_execute&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$stmt&lt;/span&gt;&lt;span class="keyword"&gt;, &amp;amp;&lt;/span&gt;&lt;span class="default"&gt;$sqldata&lt;/span&gt;&lt;span class="keyword"&gt;)) {&lt;br /&gt;    &lt;/span&gt;&lt;span class="default"&gt;$stmt &lt;/span&gt;&lt;span class="keyword"&gt;= &lt;/span&gt;&lt;span class="default"&gt;odbc_prepare&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$conn&lt;/span&gt;&lt;span class="keyword"&gt;,&lt;br /&gt;     &lt;/span&gt;&lt;span class="string"&gt;"INSERT INTO sessions (id, data) VALUES(?, ?)"&lt;/span&gt;&lt;span class="keyword"&gt;);&lt;br /&gt;    if (!&lt;/span&gt;&lt;span class="default"&gt;odbc_execute&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$stmt&lt;/span&gt;&lt;span class="keyword"&gt;, &amp;amp;&lt;/span&gt;&lt;span class="default"&gt;$sqldata&lt;/span&gt;&lt;span class="keyword"&gt;)) {&lt;br /&gt;        &lt;/span&gt;&lt;span class="comment"&gt;/* Something went wrong.. */&lt;br /&gt;    &lt;/span&gt;&lt;span class="keyword"&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;?&gt;&lt;/span&gt; &lt;/span&gt; &lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-386391598958563477?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2007/10/serialize-generates-storable.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-7767075230754828480</guid><pubDate>Thu, 25 Oct 2007 01:36:00 +0000</pubDate><atom:updated>2007-10-24T18:36:42.509-07:00</atom:updated><title>move_uploaded_file — Moves an uploaded file to a new location</title><description>bool &lt;b&gt;move_uploaded_file&lt;/b&gt; ( string $filename, string $destination )&lt;br /&gt;&lt;p&gt;    This function checks to ensure that the file designated by    &lt;i&gt;&lt;tt&gt;filename&lt;/tt&gt;&lt;/i&gt; is a valid upload file (meaning    that it was uploaded via PHP's HTTP POST upload mechanism). If    the file is valid, it will be moved to the filename given by    &lt;i&gt;&lt;tt&gt;destination&lt;/tt&gt;&lt;/i&gt;.   &lt;/p&gt;&lt;p&gt;    This sort of check is especially important if there is any chance    that anything done with uploaded files could reveal their    contents to the user, or even to other users on the same    system.   &lt;/p&gt;&lt;h2&gt;Parameters&lt;/h2&gt;&lt;p&gt;    &lt;/p&gt;&lt;div class="variablelist"&gt;&lt;dl&gt;&lt;dt&gt;&lt;span class="term"&gt;&lt;i&gt;&lt;tt&gt;filename&lt;/tt&gt;&lt;/i&gt;&lt;/span&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;        The filename of the uploaded file.       &lt;/p&gt;&lt;/dd&gt;&lt;dt&gt;&lt;span class="term"&gt;&lt;i&gt;&lt;tt&gt;destination&lt;/tt&gt;&lt;/i&gt;&lt;/span&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;        The destination of the moved file.       &lt;/p&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;/div&gt;   &lt;h2&gt;Return Values&lt;/h2&gt;&lt;p&gt;    If &lt;i&gt;&lt;tt&gt;filename&lt;/tt&gt;&lt;/i&gt; is not a valid upload file,    then no action will occur, and    &lt;b&gt;move_uploaded_file()&lt;/b&gt; will return    &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt;.   &lt;/p&gt;&lt;p&gt;    If &lt;i&gt;&lt;tt&gt;filename&lt;/tt&gt;&lt;/i&gt; is a valid upload file, but    cannot be moved for some reason, no action will occur, and    &lt;b&gt;move_uploaded_file()&lt;/b&gt; will return    &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt;. Additionally, a warning will be issued.   &lt;/p&gt;&lt;h2&gt;Notes&lt;/h2&gt;&lt;blockquote&gt;&lt;p&gt;&lt;b&gt;Note: &lt;/b&gt;     &lt;b&gt;move_uploaded_file()&lt;/b&gt; is both &lt;a href="http://in2.php.net/manual/en/features.safe-mode.php#ini.safe-mode"&gt;safe mode&lt;/a&gt;     and &lt;a href="http://in2.php.net/manual/en/features.safe-mode.php#ini.open-basedir"&gt;open_basedir&lt;/a&gt;     aware. However, restrictions are placed only on the     &lt;i&gt;&lt;tt&gt;destination&lt;/tt&gt;&lt;/i&gt; path as to allow the moving     of uploaded files in which &lt;i&gt;&lt;tt&gt;filename&lt;/tt&gt;&lt;/i&gt; may conflict     with such restrictions. &lt;b&gt;move_uploaded_file()&lt;/b&gt; ensures     the safety of this operation by allowing only those files uploaded     through PHP to be moved.    &lt;/p&gt;&lt;/blockquote&gt;&lt;b class="warning"&gt;Warning&lt;/b&gt;&lt;p&gt;     If the destination file already exists, it will be overwritten.    &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-7767075230754828480?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2007/10/moveuploadedfile-moves-uploaded-file-to.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-8630750073634252889</guid><pubDate>Thu, 25 Oct 2007 01:34:00 +0000</pubDate><atom:updated>2007-10-24T18:35:26.261-07:00</atom:updated><title>basename — Returns filename component of path</title><description>string &lt;b&gt;basename&lt;/b&gt; ( string $path [, string $suffix] )&lt;br /&gt;&lt;p&gt;    Given a string containing a path to a file, this function will return the    base name of the file.       &lt;/p&gt;&lt;h2&gt;Parameters&lt;/h2&gt;&lt;p&gt;    &lt;/p&gt;&lt;div class="variablelist"&gt;&lt;dl&gt;&lt;dt&gt;&lt;span class="term"&gt;&lt;i&gt;&lt;tt&gt;path&lt;/tt&gt;&lt;/i&gt;&lt;/span&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;        A path.       &lt;/p&gt;&lt;p&gt;        On Windows, both slash (&lt;var&gt;/&lt;/var&gt;) and backslash        (&lt;var&gt;\&lt;/var&gt;) are used as directory separator character. In        other environments, it is the forward slash (&lt;var&gt;/&lt;/var&gt;).       &lt;/p&gt;&lt;/dd&gt;&lt;dt&gt;&lt;span class="term"&gt;&lt;i&gt;&lt;tt&gt;suffix&lt;/tt&gt;&lt;/i&gt;&lt;/span&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;        If the filename ends in &lt;i&gt;&lt;tt&gt;suffix&lt;/tt&gt;&lt;/i&gt; this will also        be cut off.       &lt;/p&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;/div&gt;   &lt;h2&gt;Return Values&lt;/h2&gt;&lt;p&gt;    Returns the base name of the given &lt;i&gt;&lt;tt&gt;path&lt;/tt&gt;&lt;/i&gt;.&lt;br /&gt;&lt;/p&gt;&lt;div class="example-contents"&gt; &lt;div class="phpcode"&gt;&lt;code&gt;&lt;span class="html"&gt; &lt;span class="default"&gt;&lt;?php&lt;br /&gt;$path &lt;/span&gt;&lt;span class="keyword"&gt;= &lt;/span&gt;&lt;span class="string"&gt;"/home/httpd/html/index.php"&lt;/span&gt;&lt;span class="keyword"&gt;;&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;$file &lt;/span&gt;&lt;span class="keyword"&gt;= &lt;/span&gt;&lt;span class="default"&gt;basename&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$path&lt;/span&gt;&lt;span class="keyword"&gt;);         &lt;/span&gt;&lt;span class="comment"&gt;// $file is set to "index.php"&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;$file &lt;/span&gt;&lt;span class="keyword"&gt;= &lt;/span&gt;&lt;span class="default"&gt;basename&lt;/span&gt;&lt;span class="keyword"&gt;(&lt;/span&gt;&lt;span class="default"&gt;$path&lt;/span&gt;&lt;span class="keyword"&gt;, &lt;/span&gt;&lt;span class="string"&gt;".php"&lt;/span&gt;&lt;span class="keyword"&gt;); &lt;/span&gt;&lt;span class="comment"&gt;// $file is set to "index"&lt;br /&gt;&lt;/span&gt;&lt;span class="default"&gt;?&gt;&lt;/span&gt; &lt;/span&gt; &lt;/code&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-8630750073634252889?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2007/10/basename-returns-filename-component-of.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-6300121330482468396</guid><pubDate>Thu, 25 Oct 2007 01:32:00 +0000</pubDate><atom:updated>2007-10-24T18:33:40.000-07:00</atom:updated><title>glob-Find pathnames matching a pattern</title><description>array &lt;b&gt;glob&lt;/b&gt; ( string $pattern [, int $flags] )&lt;br /&gt;&lt;p&gt;    The &lt;b&gt;glob()&lt;/b&gt; function searches for all the pathnames    matching &lt;i&gt;&lt;tt&gt;pattern&lt;/tt&gt;&lt;/i&gt; according to the rules used by    the libc glob() function, which is similar to the rules used by common    shells.   &lt;/p&gt;&lt;h2&gt;Parameters&lt;/h2&gt;&lt;p&gt;    &lt;/p&gt;&lt;div class="variablelist"&gt;&lt;dl&gt;&lt;dt&gt;&lt;span class="term"&gt;&lt;i&gt;&lt;tt&gt;pattern&lt;/tt&gt;&lt;/i&gt;&lt;/span&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;        The pattern. No tilde expansion or parameter substitution is done.       &lt;/p&gt;&lt;/dd&gt;&lt;dt&gt;&lt;span class="term"&gt;&lt;i&gt;&lt;tt&gt;flags&lt;/tt&gt;&lt;/i&gt;&lt;/span&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;        Valid flags:        &lt;/p&gt;&lt;div class="itemizedlist"&gt;&lt;ul type="disc"&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_MARK&lt;/tt&gt;&lt;/b&gt; - Adds a slash to each item returned          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_NOSORT&lt;/tt&gt;&lt;/b&gt; - Return files as they appear in the           directory (no sorting)          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_NOCHECK&lt;/tt&gt;&lt;/b&gt; - Return the search pattern if no           files matching it were found          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_NOESCAPE&lt;/tt&gt;&lt;/b&gt; - Backslashes do not quote           metacharacters          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_BRACE&lt;/tt&gt;&lt;/b&gt; - Expands {a,b,c} to match 'a', 'b',           or 'c'          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_ONLYDIR&lt;/tt&gt;&lt;/b&gt; - Return only directory entries           which match the pattern          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_ERR&lt;/tt&gt;&lt;/b&gt; - Stop on read errors (like unreadable           directories), by default errors are ignored.          &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;p&gt;       &lt;/p&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;/div&gt;   &lt;h2&gt;Return Values&lt;/h2&gt;&lt;p&gt;    Returns an array containing the matched files/directories, an empty array    if no file matched or &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt; on error.   &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-6300121330482468396?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2007/10/glob-find-pathnames-matching-pattern.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-7160289336937294572</guid><pubDate>Sun, 09 Sep 2007 15:16:00 +0000</pubDate><atom:updated>2007-09-09T08:17:20.852-07:00</atom:updated><title>glob</title><description>&lt;p&gt;glob — Find pathnames matching a pattern&lt;/p&gt;&lt;h2&gt;Description&lt;/h2&gt;array &lt;b&gt;glob&lt;/b&gt; ( string $pattern [, int $flags] )&lt;br /&gt;&lt;p&gt;    The &lt;b&gt;glob()&lt;/b&gt; function searches for all the pathnames    matching &lt;i&gt;&lt;tt&gt;pattern&lt;/tt&gt;&lt;/i&gt; according to the rules used by    the libc glob() function, which is similar to the rules used by common    shells.   &lt;/p&gt;&lt;h2&gt;Parameters&lt;/h2&gt;&lt;p&gt;    &lt;/p&gt;&lt;div class="variablelist"&gt;&lt;dl&gt;&lt;dt&gt;&lt;span class="term"&gt;&lt;i&gt;&lt;tt&gt;pattern&lt;/tt&gt;&lt;/i&gt;&lt;/span&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;        The pattern. No tilde expansion or parameter substitution is done.       &lt;/p&gt;&lt;/dd&gt;&lt;dt&gt;&lt;span class="term"&gt;&lt;i&gt;&lt;tt&gt;flags&lt;/tt&gt;&lt;/i&gt;&lt;/span&gt;&lt;/dt&gt;&lt;dd&gt;&lt;p&gt;        Valid flags:        &lt;/p&gt;&lt;div class="itemizedlist"&gt;&lt;ul type="disc"&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_MARK&lt;/tt&gt;&lt;/b&gt; - Adds a slash to each item returned          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_NOSORT&lt;/tt&gt;&lt;/b&gt; - Return files as they appear in the           directory (no sorting)          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_NOCHECK&lt;/tt&gt;&lt;/b&gt; - Return the search pattern if no           files matching it were found          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_NOESCAPE&lt;/tt&gt;&lt;/b&gt; - Backslashes do not quote           metacharacters          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_BRACE&lt;/tt&gt;&lt;/b&gt; - Expands {a,b,c} to match 'a', 'b',           or 'c'          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_ONLYDIR&lt;/tt&gt;&lt;/b&gt; - Return only directory entries           which match the pattern          &lt;/li&gt;&lt;li&gt;           &lt;b&gt;&lt;tt&gt;GLOB_ERR&lt;/tt&gt;&lt;/b&gt; - Stop on read errors (like unreadable           directories), by default errors are ignored.          &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;p&gt;       &lt;/p&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;/div&gt;   &lt;h2&gt;Return Values&lt;/h2&gt;&lt;p&gt;    Returns an array containing the matched files/directories, an empty array    if no file matched or &lt;b&gt;&lt;tt&gt;FALSE&lt;/tt&gt;&lt;/b&gt; on error.   &lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-7160289336937294572?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2007/09/glob.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-1242250651508452334</guid><pubDate>Thu, 16 Aug 2007 10:25:00 +0000</pubDate><atom:updated>2007-08-16T03:26:53.962-07:00</atom:updated><title>ini_set()</title><description>string ini_set ( string $varname, string $newvalue )&lt;br /&gt;Sets the value of the given configuration option. The configuration option will keep this new value during the script's execution, and will be restored at the script's ending.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-1242250651508452334?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2007/08/iniset.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-5764422694483596964</guid><pubDate>Thu, 16 Aug 2007 10:22:00 +0000</pubDate><atom:updated>2007-08-16T03:23:42.164-07:00</atom:updated><title>PHP Objects</title><description>Basic &lt;a title="Object-oriented programming" href="http://en.wikipedia.org/wiki/Object-oriented_programming"&gt;Object-oriented programming&lt;/a&gt; functionality was added in PHP 3. Handling of objects was completely rewritten for PHP 5, allowing for better performance and more features. In previous versions of PHP, objects were handled like &lt;a title="Primitive type" href="http://en.wikipedia.org/wiki/Primitive_type"&gt;primitive types&lt;/a&gt;. The drawback of this method was that the whole object was copied when a variable was assigned, or passed as a parameter to a method. In the new approach, objects are referenced by &lt;a title="Smart pointer" href="http://en.wikipedia.org/wiki/Smart_pointer#Handles"&gt;handle&lt;/a&gt;, and not by value. PHP 5 introduced private and protected &lt;a title="Member variable" href="http://en.wikipedia.org/wiki/Member_variable"&gt;member variables&lt;/a&gt; and methods, along with &lt;a title="Class (computer science)" href="http://en.wikipedia.org/wiki/Class_%28computer_science%29#Abstract_and_concrete_classes"&gt;abstract classes&lt;/a&gt; and &lt;a title="Abstract method" href="http://en.wikipedia.org/wiki/Abstract_method"&gt;abstract methods&lt;/a&gt;. It also introduced a standard way of declaring &lt;a title="Constructor (computer science)" href="http://en.wikipedia.org/wiki/Constructor_%28computer_science%29"&gt;constructors&lt;/a&gt; and &lt;a title="Destructor (computer science)" href="http://en.wikipedia.org/wiki/Destructor_%28computer_science%29"&gt;destructors&lt;/a&gt; similar to that of other object-oriented languages, such as C++, and an &lt;a title="Exception handling" href="http://en.wikipedia.org/wiki/Exception_handling"&gt;exception handling&lt;/a&gt; model similar to that of other programming languages.&lt;br /&gt;The static method and class variable features in Zend Engine 2 do not work the way some expect. There is no &lt;a title="Virtual table" href="http://en.wikipedia.org/wiki/Virtual_table"&gt;virtual table&lt;/a&gt; feature in the engine, so the &lt;a title="Static variable" href="http://en.wikipedia.org/wiki/Static_variable"&gt;static variables&lt;/a&gt; are bound with a name at compile time instead of with a reference.&lt;br /&gt;class foo extends bar&lt;br /&gt;{&lt;br /&gt;function __construct()&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;public static function thisstaticfunc()&lt;br /&gt;{&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;The above very basic example shows how to define a class, foo, that inherits from class bar. Additionally, the function, mystaticfunc, is a public static function that is called with foo::thisstaticfunc();.&lt;br /&gt;If the developer asks to create a copy of an object by using the reserved word clone, the Zend engine will check if a __clone() method has been defined or not. If not, it will call a default __clone() which will copy all of the object's properties. If a __clone() method is defined, then it will be responsible for setting the necessary properties in the created object. For convenience, the engine will supply a function that imports all of the properties from the source object, so that they can start with a by-value &lt;a class="extiw" title="wiktionary:replica" href="http://en.wiktionary.org/wiki/replica"&gt;replica&lt;/a&gt; of the source object, and only override properties that need to be changed&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-5764422694483596964?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2007/08/php-objects.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-854324425976782392</guid><pubDate>Thu, 16 Aug 2007 10:22:00 +0000</pubDate><atom:updated>2007-08-16T03:22:39.999-07:00</atom:updated><title>PHP Data types</title><description>PHP stores whole numbers in a platform-dependent range. This range is typically that of 32-bit signed integers. Integer variables can be assigned using decimal (positive and negative), &lt;a title="Octal" href="http://en.wikipedia.org/wiki/Octal"&gt;octal&lt;/a&gt; and &lt;a title="Hexadecimal" href="http://en.wikipedia.org/wiki/Hexadecimal"&gt;hexadecimal&lt;/a&gt; notations. &lt;a title="Real numbers" href="http://en.wikipedia.org/wiki/Real_numbers"&gt;Real numbers&lt;/a&gt; are also stored in a platform-specific range. They can be specified using &lt;a title="Floating point" href="http://en.wikipedia.org/wiki/Floating_point"&gt;floating point&lt;/a&gt; notation, or two forms of &lt;a title="Scientific notation" href="http://en.wikipedia.org/wiki/Scientific_notation"&gt;scientific notation&lt;/a&gt;.&lt;br /&gt;PHP has a native &lt;a title="Boolean" href="http://en.wikipedia.org/wiki/Boolean"&gt;Boolean&lt;/a&gt; type, named "boolean", similar to the native Boolean types in &lt;a title="Java (programming language)" href="http://en.wikipedia.org/wiki/Java_%28programming_language%29"&gt;Java&lt;/a&gt; and &lt;a title="C++" href="http://en.wikipedia.org/wiki/C%2B%2B"&gt;C++&lt;/a&gt;. Using the Boolean type conversion rules, non-zero values can be interpreted as true and zero as false, as in Perl.&lt;br /&gt;The null data type represents a variable that has no value. The only value in the null data type is NULL.&lt;br /&gt;Variables of the "resource" type represent references to resources from external sources. These are typically created by functions from a particular extension, and can only be processed by functions from the same extension. Examples include file, image and database resources.&lt;br /&gt;&lt;a title="Array" href="http://en.wikipedia.org/wiki/Array"&gt;Arrays&lt;/a&gt; support both numeric and string indices, and are &lt;a title="Heterogeneous" href="http://en.wikipedia.org/wiki/Heterogeneous"&gt;heterogeneous&lt;/a&gt;. Arrays can contain elements of any type that PHP can handle, including resources, objects, and even other arrays. Order is preserved in lists of values and in &lt;a title="Hash table" href="http://en.wikipedia.org/wiki/Hash_table"&gt;hashes&lt;/a&gt; with both keys and values, and the two can be intermingled&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-854324425976782392?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2007/08/php-data-types.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item><item><guid isPermaLink='false'>tag:blogger.com,1999:blog-2865552588131115943.post-4068011178444289330</guid><pubDate>Thu, 16 Aug 2007 10:21:00 +0000</pubDate><atom:updated>2007-08-16T03:22:06.437-07:00</atom:updated><title>PHP Command-line scripting</title><description>PHP also provides a &lt;a title="Command line interface" href="http://en.wikipedia.org/wiki/Command_line_interface"&gt;command line interface&lt;/a&gt; &lt;a title="Server Application Programming Interface" href="http://en.wikipedia.org/wiki/Server_Application_Programming_Interface"&gt;SAPI&lt;/a&gt; for developing shell and desktop applications, daemons, log parsing, or other system administration tasks. PHP is increasingly used on the command line for tasks that have traditionally been the domain of &lt;a title="Perl" href="http://en.wikipedia.org/wiki/Perl"&gt;Perl&lt;/a&gt;, &lt;a title="Python (programming language)" href="http://en.wikipedia.org/wiki/Python_%28programming_language%29"&gt;Python&lt;/a&gt;, &lt;a title="Awk" href="http://en.wikipedia.org/wiki/Awk"&gt;awk&lt;/a&gt;, or &lt;a title="Shell script" href="http://en.wikipedia.org/wiki/Shell_script"&gt;shell scripting&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2865552588131115943-4068011178444289330?l=php-teacher.blogspot.com' alt='' /&gt;&lt;/div&gt;</description><link>http://php-teacher.blogspot.com/2007/08/php-command-line-scripting.html</link><author>noreply@blogger.com (PHP Codes)</author><thr:total xmlns:thr='http://purl.org/syndication/thread/1.0'>0</thr:total></item></channel></rss>