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

<channel>
	<title>SamplePhpCodes.com</title>
	<atom:link href="http://www.samplephpcodes.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.samplephpcodes.com</link>
	<description>Get PHP Code Help, Sample PHP Scripts,PHP Script Demos</description>
	<lastBuildDate>Mon, 05 Apr 2010 15:39:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PHP Introduction</title>
		<link>http://www.samplephpcodes.com/php-tutorials/php-basics/php-introduction/</link>
		<comments>http://www.samplephpcodes.com/php-tutorials/php-basics/php-introduction/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 13:47:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Basics]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=35</guid>
		<description><![CDATA[Introduction to PHP Introduction PHP is a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. PHP stands for PHP: Hypertext Preprocessor. It is a server-side scripting language, like ASP. A simple example &#60;html&#62; &#60;head&#62; &#60;title&#62;Example&#60;/title&#62; &#60;/head&#62; &#60;body&#62; &#60;?php echo &#34;Hi, I'm a PHP script!&#34;; [...]]]></description>
			<content:encoded><![CDATA[<p>Introduction to PHP<br />
Introduction<br />
PHP is  a widely-used Open Source general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. PHP stands for PHP: Hypertext Preprocessor. It is a server-side scripting language, like ASP. </p>
<p>                    A simple example</p>
<pre class="brush: php;">

&lt;html&gt;
   &lt;head&gt;
      &lt;title&gt;Example&lt;/title&gt;
   &lt;/head&gt;
    &lt;body&gt;
      &lt;?php
        echo &quot;Hi, I'm a PHP script!&quot;;
       ?&gt;

    &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>PHP scripts are executed on the server.  PHP supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.). PHP is free to download and use.<br />
<strong></strong><br />
<strong>PHP file</strong><br />
<strong></strong><br />
          PHP files may contain text, HTML tags and scripts. PHP files are returned to the browser as plain HTML. PHP files have a file extension of &#8220;.php&#8221;, &#8220;.php3&#8243;, or &#8220;.phtml&#8221; .<br />
<strong></strong><br />
<strong>Why PHP?</strong><br />
<strong></strong><br />
         PHP runs on different platforms (Windows, Linux, Unix, etc.). PHP is compatible with almost all servers used today (Apache, IIS, etc.). PHP is FREE to download from the official PHP resource: www.php.net. PHP is easy to learn and runs efficiently on the server side .<br />
<strong></strong><br />
<strong>Mysql</strong><br />
  <strong></strong><br />
           MySQL is a database server. MySQL is ideal for both small and large applications. MySQL supports standard SQL.  MySQL compiles on a number of platforms. MySQL is free to download and use.<br />
<strong></strong><br />
<strong>PHP + MySQL</strong><br />
<strong></strong><br />
              PHP combined with MySQL are cross-platform (means that you can develop in Windows and serve on a Unix platform)<br />
<strong></strong><br />
<strong>Where to Start?</strong><br />
<strong></strong><br />
            Install an Apache server on a Windows or Linux machine. Install PHP on a Windows or Linux machine. Install MySQL on a Windows or Linux machine .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/php-tutorials/php-basics/php-introduction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing PHP</title>
		<link>http://www.samplephpcodes.com/php-tutorials/php-basics/installing-php/</link>
		<comments>http://www.samplephpcodes.com/php-tutorials/php-basics/installing-php/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 13:58:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Basics]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[installing php]]></category>
		<category><![CDATA[LAMP]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php install]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=37</guid>
		<description><![CDATA[Installation Download PHP Download PHP for free from: http://www.php.net/downloads.php Download MySQL Database Download MySQL for free from: http://www.mysql.com/downloads/index.html Download Apache Server Download Apache for free here: http://httpd.apache.org/download.cgi This section contains notes and hints specific to Apache 2.0 installs of PHP on Unix systems. Installation Instructions (Apache Shared Module Version) for PHP First download the php [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Installation<br />
</strong><br />
         <strong> Download PHP      </strong><br />
<strong>  </strong><br />
          Download PHP for free from: <a href="http://www.php.net/downloads.php">http://www.php.net/downloads.php</a><br />
<strong></strong><br />
<strong> Download MySQL Database</strong><br />
<strong></strong><br />
          Download MySQL for free from: <a href="http://www.mysql.com/downloads/index.html">http://www.mysql.com/downloads/index.html</a><br />
<strong></strong><br />
          <strong>Download Apache Server</strong><br />
          Download Apache for free here: <a href="http://httpd.apache.org/download.cgi">http://httpd.apache.org/download.cgi</a><br />
                This section contains notes and hints specific to Apache 2.0<br />
<strong></strong><br />
<strong>installs of PHP on Unix systems.</strong><br />
<strong></strong><br />
Installation Instructions (Apache Shared Module Version) for PHP<br />
         First download the php tar file and the apache tar file.The version numbers have been omitted here, to ensure the instructions are not incorrect. You will need to replace the &#8216;xxx&#8217; here with the correct values from your files. Then follow the below steps<br />
If you get the .tar.gz file then use step 1 to extract or if you get the .tar file use step 2.<br />
1.  gunzip apache_xxx.tar.gz<br />
2.  tar -xvf apache_xxx.tar<br />
3.  gunzip php-xxx.tar.gz<br />
4.  tar -xvf php-xxx.tar<br />
5.  cd apache_xxx<br />
6.  ./configure &#8211;prefix=/www &#8211;enable-module=so<br />
7.  make<br />
8.  make install<br />
9.  cd ../php-xxx </p>
<p>10. Now, configure your PHP.<br />
      This is where you customize your PHP  with various options, like which extensions will be enabled.<br />
      Do a  ./configure &#8211;help for a list of available options.<br />
      Here we&#8217;ll do a simple configure with Apache 1 and MySQL support.  Your path to apxs may differ from our example.<br />
      ./configure &#8211;with-mysql &#8211;with-apxs=/www/bin/apxs</p>
<p>11. make<br />
12. make install<br />
   If you decide to change your configure options after installation,<br />
    you only need to repeat the last three steps. You only need to<br />
    restart apache for the new module to take effect. A recompile of<br />
    Apache is not needed.</p>
<p>    Note that unless told otherwise, &#8216;make install&#8217; will also install PEAR,<br />
    various PHP tools such as phpize, install the PHP CLI, and more.</p>
<p>13. Setup your php.ini file:<br />
      cp php.ini-dist /usr/local/lib/php.ini<br />
     You may edit your .ini file to set PHP options.  If you prefer your<br />
    php.ini in another location, use &#8211;with-config-file-path=/some/path in<br />
    step 10. </p>
<p>    If you instead choose php.ini-recommended, be certain to read the list<br />
    of changes within, as they affect how PHP behaves.</p>
<p>14. Edit your httpd.conf to load the PHP module.  The path on the right hand<br />
    side of the LoadModule statement must point to the path of the PHP<br />
    module on your system.  The make install from above may have already<br />
    added this for you, but be sure to check.<br />
    For PHP 4:<br />
      LoadModule php4_module libexec/libphp4.so<br />
    For PHP 5:<br />
      LoadModule php5_module libexec/libphp5.so</p>
<p>15. And in the AddModule section of httpd.conf, somewhere under the ClearModuleList, add this:<br />
    For PHP 4:<br />
      AddModule mod_php4.c<br />
    For PHP 5:<br />
      AddModule mod_php5.c</p>
<p>16. Tell Apache to parse certain extensions as PHP.  For example,<br />
    let&#8217;s have Apache parse the .php extension as PHP.  You could<br />
    have any extension(s) parse as PHP by simply adding more, with<br />
    each separated by a space.  We&#8217;ll add .phtml to demonstrate.</p>
<p>      AddType application/x-httpd-php .php .phtml</p>
<p>    It&#8217;s also common to setup the .phps extension to show highlighted PHP<br />
    source, this can be done with:</p>
<p>      AddType application/x-httpd-php-source .phps</p>
<p>17. Use your normal procedure for starting the Apache server. (You must<br />
    stop and restart the server, not just cause the server to reload by<br />
    using a HUP or USR1 signal.)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/php-tutorials/php-basics/installing-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Syntax</title>
		<link>http://www.samplephpcodes.com/php-tutorials/php-basics/php-syntax/</link>
		<comments>http://www.samplephpcodes.com/php-tutorials/php-basics/php-syntax/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 14:02:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Basics]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=41</guid>
		<description><![CDATA[Syntax A PHP scripting block always starts with . A PHP scripting block can be placed anywhere in the document. &#60;?php ?&#62; A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code. First PHP- enables page Create a file named hello.php and put it in your web server&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Syntax </strong><br />
<strong></strong><br />
A PHP scripting block always starts with <?php and ends with ?>. A PHP scripting block can be placed anywhere in the document.</p>
<pre class="brush: php;">&lt;?php
?&gt;</pre>
<p>A PHP file normally contains HTML tags, just like an HTML file, and some PHP scripting code.<br />
<strong></strong><br />
<strong>First PHP- enables page</strong><br />
<strong></strong><br />
Create a file named hello.php and put it in your web server&#8217;s root directory (DOCUMENT_ROOT) with the following content<br />
<strong></strong><br />
<strong> Our first PHP script: hello.php</strong></p>
<pre class="brush: php;">&lt;html&gt;
 &lt;head&gt;
 &lt;title&gt;PHP Test&lt;/title&gt;
 &lt;/head&gt;
 &lt;body&gt;
 &lt;?php echo '&lt;p&gt;Hello World&lt;/p&gt;'; ?&gt;
 &lt;/body&gt;
&lt;/html&gt;
</pre>
<p>  Each code line in PHP must end with a semicolon. The semicolon is a separator and is used to distinguish one set of instructions from another.</p>
<p>                     There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text &#8220;Hello World&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/php-tutorials/php-basics/php-syntax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Variables</title>
		<link>http://www.samplephpcodes.com/php-tutorials/php-basics/php-variables/</link>
		<comments>http://www.samplephpcodes.com/php-tutorials/php-basics/php-variables/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 14:05:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Basics]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=24</guid>
		<description><![CDATA[Variables Variables are used for storing a values, like text strings, numbers or arrays. When a variable is set it can be used over and over again. Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive. The correct way of setting a variable [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Variables </strong><br />
   Variables are used for storing a values, like text strings, numbers or arrays. When a variable is set it can be used over and over again. Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive. </p>
<p>The correct way of setting a variable in PHP:<br />
      $var_name = value;</p>
<p>Predefined variables<br />
                    PHP provides a large number of predefined variables to any script which it runs.<br />
<strong></strong><br />
<strong>PHP Superglobals</strong><br />
<strong></strong><br />
<strong> $GLOBALS </strong><br />
<strong></strong><br />
 Contains a reference to every variable which is currently available within the global scope of the script. The keys of this array are the names of the global variables. $GLOBALS has existed since PHP 3.<br />
<strong></strong><br />
<strong>$_SERVER </strong><br />
<strong></strong><br />
 Variables set by the web server or otherwise directly related to the execution environment of the current script. Analogous to the old $HTTP_SERVER_VARS array (which is still available, but deprecated).<br />
<strong></strong><br />
<strong>$_GET </strong><br />
<strong></strong><br />
 Variables provided to the script via URL query string. Analogous to the old $HTTP_GET_VARS array (which is still available, but deprecated).<br />
<strong></strong><br />
<strong>$_POST </strong><br />
<strong></strong><br />
 Variables provided to the script via HTTP POST. Analogous to the old $HTTP_POST_VARS array (which is still available, but deprecated).<br />
 <strong></strong><br />
<strong>$_COOKIE </strong><br />
<strong></strong><br />
 Variables provided to the script via HTTP cookies. Analogous to the old $HTTP_COOKIE_VARS array (which is still available, but deprecated).<br />
<strong></strong><br />
<strong>$_FILES </strong><br />
<strong></strong><br />
 Variables provided to the script via HTTP post file uploads. Analogous to the old $HTTP_POST_FILES array (which is still available, but deprecated). See POST method uploads for more information.<br />
<strong></strong><br />
<strong>$_ENV </strong><br />
<strong></strong><br />
 Variables provided to the script via the environment. Analogous to the old $HTTP_ENV_VARS array (which is still available, but deprecated).<br />
 <strong></strong><br />
<strong>$_REQUEST </strong><br />
<strong></strong><br />
 Variables provided to the script via the GET, POST, and COOKIE input mechanisms, and which therefore cannot be trusted.<br />
<strong></strong><br />
<strong>$_SESSION </strong><br />
<strong></strong><br />
 Variables which are currently registered to a script&#8217;s session.<br />
<strong></strong><br />
<strong>Variable scope</strong><br />
<strong></strong><br />
         The scope of a variable is the context within which it is defined. For the most part all PHP variables only have a single scope. This single scope spans included and required files as well.</p>
<p>For example</p>
<pre class="brush: php;">&lt;?php
$a = 1;
include 'b.inc';
?&gt;</pre>
<p>Here the $a variable will be available within the included b.inc script. However, within user-defined functions a local function scope is introduced. Any variable used inside a function is by default limited to the local function scope. </p>
<p>Variable Naming Rules<br />
A variable name must start with a letter or an underscore &#8220;_&#8221;<br />
A variable name can only contain alpha-numeric characters and underscores (a-Z, 0-9, and _ )<br />
A variable name should not contain spaces. If a variable name is more than one word, it should be separated with underscore ($my_string), or with capitalization ($myString) </p>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/php-tutorials/php-basics/php-variables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Strings</title>
		<link>http://www.samplephpcodes.com/php-tutorials/php-basics/php-strings/</link>
		<comments>http://www.samplephpcodes.com/php-tutorials/php-basics/php-strings/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 14:15:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Basics]]></category>
		<category><![CDATA[Concatenation]]></category>
		<category><![CDATA[String]]></category>
		<category><![CDATA[strpos()]]></category>
		<category><![CDATA[str_repeat()]]></category>
		<category><![CDATA[str_replace()]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=6</guid>
		<description><![CDATA[String variables are used for values that contains character strings. A string can be used directly in a function or it can be stored in a variable. For example &#60;?php $txt=&#34;Hello World&#34;; echo $txt; ?&#62; The output of the code Hello World The Concatenation Operator There is only one string operator in PHP. The concatenation [...]]]></description>
			<content:encoded><![CDATA[<p>String variables are used for values that contains character strings. A string can be used directly in a function or it can be stored in a variable.<br />
For example    </p>
<pre class="brush: php;">
&lt;?php
$txt=&quot;Hello World&quot;;
echo $txt;
?&gt;</pre>
<p>
The output of the code<br />
           Hello World<br />
<br />
<strong>The Concatenation Operator</strong><br />
<br />
          There is only one string operator in PHP. The concatenation operator (.)  is used to put two string values together. To concatenate two variables together, use the dot (.) operator</p>
<pre class="brush: php;">&lt;?php
$txt1=&quot;Hello World&quot;;
$txt2=&quot;1234&quot;;
echo $txt1 . &quot; &quot; . $txt2;
?&gt;</pre>
<p>Output  :    Hello World 1234<br />
<br />
<strong>strpos() function</strong><br />
<br />
      The strpos() function is used to search for a string or character within a string.<br />
           int strpos ( string $haystack , mixed $needle [, int $offset ] )<br />
If a match is found in the string, this function will return the position of the first match. If no match is found, it will return FALSE.<br />
For example</p>
<pre class="brush: php;">&lt;?php
echo strpos(&quot;Hello world!&quot;,&quot;world&quot;);
?&gt;</pre>
<p>
Output : 6<br />
</p>
<p><strong>strlen() function</strong><br />
<br />
          The strlen() function is used to find the length of a string.<br />
                     int strlen ( string $string )</p>
<pre class="brush: php;">&lt;?php
echo strlen(&quot;Hello world!&quot;);
?&gt;</pre>
<p>
 Output : 12.<br />
<br />
               The length of a string is often used in loops or other functions, when it is important to know when the string ends.<br />
<br />
<strong>str_repeat() function</strong><br />
<br />
          The str_repeat function is used to repeat a string.<br />
           string str_repeat ( string $input , int $multiplier )</p>
<pre class="brush: php;">&lt;?php
echo str_repeat(&quot;-=&quot;, 10);
?&gt;</pre>
<p>
 Output :  -=-=-=-=-=-=-=-=-=-=<br />
<br />
<strong>str_replace() function</strong><br />
<br />
       The str_replace function is used to replace all occurrences of the search string with the replacement string. This function returns a string or an array with the replaced values.</p>
<pre class="brush: php;">&lt;?php
$phrase  = &quot;You should eat fruits, vegetables, and fiber every day.&quot;;
$healthy = array(&quot;fruits&quot;, &quot;vegetables&quot;, &quot;fiber&quot;);
$yummy   = array(&quot;pizza&quot;, &quot;beer&quot;, &quot;ice cream&quot;);
$newphrase = str_replace($healthy, $yummy, $phrase);
echo $newphrase;
?&gt;</pre>
<p>
 Output : You should eat pizza, beer, fiber</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/php-tutorials/php-basics/php-strings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a File In PHP</title>
		<link>http://www.samplephpcodes.com/php-tutorials/php-file-functions/creating-a-file-in-php/</link>
		<comments>http://www.samplephpcodes.com/php-tutorials/php-file-functions/creating-a-file-in-php/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 14:11:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP File Functions]]></category>
		<category><![CDATA[fclose]]></category>
		<category><![CDATA[File Create]]></category>
		<category><![CDATA[fopen]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=30</guid>
		<description><![CDATA[File Create The fopen 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). Since we [...]]]></description>
			<content:encoded><![CDATA[<p><strong>File Create </strong><br />
<strong></strong><br />
The fopen 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).<br />
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.<br />
<strong></strong></p>
<pre class="brush: php;">$ourFileName = &quot;testFile.txt&quot;;
$ourFileHandle = fopen($ourFileName, 'w') or die(&quot;can't open file&quot;);
fclose($ourFileHandle);</pre>
<p>The file &#8220;testFile.txt&#8221; should be created in the same directory where this PHP code resides. PHP will see that &#8220;testFile.txt&#8221; does not exist and will create it after running this code. There&#8217;s a lot of information in those three lines of code, let&#8217;s make sure you understand it.<br />
<strong></strong><br />
<strong>1.$ourFileName = &#8220;testFile.txt&#8221;; </strong><br />
<strong></strong><br />
Here we create the name of our file, &#8220;testFile.txt&#8221; and store it into a  PHP String variable $ourFileName.<br />
<strong>2.$ourFileHandle = fopen($ourFileName, &#8216;w&#8217;) or die(&#8220;can&#8217;t open file&#8221;); </strong><br />
This bit of code actually has two parts. First we use the function fopen and give it two arguments: our file name and we inform PHP that we want to write by passing the character &#8220;w&#8221;.<br />
Second, the fopen function returns what is called a file handle, which will allow us to manipulate the file. We save the file handle into the $ourFileHandle variable. We will talk more about file handles later on.<br />
<strong></strong><br />
<strong>1.fclose($ourFileHandle); </strong><br />
<strong></strong><br />
We close the file that was opened. fclose takes the file handle that is to be closed. We will talk more about this more in the file closing lesson.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/php-tutorials/php-file-functions/creating-a-file-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP File Operations In Different Modes</title>
		<link>http://www.samplephpcodes.com/php-tutorials/php-file-functions/php-file-opeartion-in-different-modes/</link>
		<comments>http://www.samplephpcodes.com/php-tutorials/php-file-functions/php-file-opeartion-in-different-modes/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 14:37:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP File Functions]]></category>
		<category><![CDATA[fopen]]></category>
		<category><![CDATA[fopen a]]></category>
		<category><![CDATA[fopen r]]></category>
		<category><![CDATA[fopen w]]></category>
		<category><![CDATA[fopen x]]></category>
		<category><![CDATA[x+.]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=28</guid>
		<description><![CDATA[File Open A file can be opened using fopen function. Two parameters that must pass to this function are file name and mode. On success fopen returns a file pointer , or FALSE on error. Modes that can be used with fopen are r, r+, w, w+, a, a+, x, x+. Difference between mode &#8216;r&#8217; [...]]]></description>
			<content:encoded><![CDATA[<p><strong>File Open </strong><br />
A file can be opened using fopen function. Two parameters that must pass to this function are<br />
 file name and mode. On success fopen returns a file pointer , or  FALSE on error.  Modes that can be used with fopen are  r,  r+,  w, w+,  a,  a+,  x, x+.<br />
            Difference between  mode &#8216;r&#8217; and  &#8216;r+&#8217; :  fopen with mode r open a file for reading, whereas r+ open a file for reading and writing .<br />
	Difference between mode  &#8216;w&#8217; and &#8216;w+&#8217;:  fopen with mode w open a file for writing only, but w+ allows both reading and writing operation.<br />
           Difference between  mode &#8216;a&#8217; and &#8216;a+&#8217;:    fopen with mode &#8216;a&#8217; allow only writing to the file but &#8216;a+&#8217;  permits both reading and writing operation.<br />
	Difference between mode  &#8216;x&#8217; and &#8216;x+&#8217;:  fopen with &#8216;x&#8217;  allows only writing to the file, but &#8216;x+&#8217; permits both reading and writing.<br />
	Main difference between  mode &#8216;w&#8217; and &#8216;a&#8217;:   If the file we are trying to open with mode &#8216;w&#8217; already exist, fopen truncates length  of the file to zero, and write the new content at the beginning of the file.<br />
 If the mode  used to open an already existing file is  &#8216;a&#8217;, new content would be appended  to the end of the file.<br />
            Main difference between  mode &#8216;w&#8217; and &#8216;x&#8217; : both mode open a file for writing only and file pointer points to the beginning of the file ,  difference is  if  the file already exist.   fopen with mode &#8216;x&#8217; returns FALSE if  the file  already exist  whereas fopen with mode &#8216;w&#8217;  truncates  length of the file to zero and write content  at the beginning.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/php-tutorials/php-file-functions/php-file-opeartion-in-different-modes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP – File Read function</title>
		<link>http://www.samplephpcodes.com/php-tutorials/php-file-functions/php-%e2%80%93-file-read-function/</link>
		<comments>http://www.samplephpcodes.com/php-tutorials/php-file-functions/php-%e2%80%93-file-read-function/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 14:24:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP File Functions]]></category>
		<category><![CDATA[File operations in PHP]]></category>
		<category><![CDATA[file read]]></category>
		<category><![CDATA[Open file in read mode]]></category>
		<category><![CDATA[reading a file in PHP]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=16</guid>
		<description><![CDATA[File Read fread function is used to read content of a file. file pointer and number of bytes to be read are parameters that fread function required. fread returns string read on success or FALSE on failiure. Example of reading content of a file: &#60;?php $filename = 'example.txt'; if (! ($fp = fopen($filename, 'r') ) [...]]]></description>
			<content:encoded><![CDATA[<p><strong>File Read </strong><br />
 fread function is used to read content of a file. file pointer and number of bytes to be read are  parameters that fread function required. fread returns string read on success or FALSE on failiure.<br />
           Example of reading content of a file:</p>
<pre class="brush: php;">&lt;?php
    $filename = 'example.txt';
    if (! ($fp = fopen($filename, 'r') ) ) {
    echo 'Unable to open file '. $filename;
    }else {
    $file_size = filesize($filename);
    if (  !($contents = fread($fp, $file_size)  ) ) {
    echo 'Error: read operation failed';
    }else{
    echo 'content read is ' . $contents;
    }
    fclose($fp);
    }
   ?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/php-tutorials/php-file-functions/php-%e2%80%93-file-read-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP File write function</title>
		<link>http://www.samplephpcodes.com/php-tutorials/php-file-functions/php-file-write-function/</link>
		<comments>http://www.samplephpcodes.com/php-tutorials/php-file-functions/php-file-write-function/#comments</comments>
		<pubDate>Sat, 17 Oct 2009 14:27:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP File Functions]]></category>
		<category><![CDATA[File operations in PHP]]></category>
		<category><![CDATA[file read]]></category>
		<category><![CDATA[Open file in write mode]]></category>
		<category><![CDATA[writing a file in PHP]]></category>
		<category><![CDATA[writing data into a file]]></category>
		<category><![CDATA[writing data to file in PHP]]></category>
		<category><![CDATA[writing text file]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=20</guid>
		<description><![CDATA[File Write fwrite function is used to write contents to a file. fwrite needs file pointer and contents of type string as parameters. fwrite returns number of bytes written on success , or FALSE on error. Example : &#60;?php $content = 'This content is to test'; if ( is_writable ('example.txt') ){ $fp = fopen ('example.txt', [...]]]></description>
			<content:encoded><![CDATA[<p><strong>File Write </strong><br />
<strong></strong><br />
fwrite function is used to write  contents to a file.  fwrite needs  file pointer and  contents of type  string  as parameters. fwrite returns number of bytes written on<br />
success  , or FALSE on error.<br />
             Example :</p>
<pre class="brush: php;">&lt;?php
    $content =  'This content is to test';
    if ( is_writable ('example.txt') ){
    $fp = fopen ('example.txt', 'w');
    if (  !$fp ){
    echo 'error : coud not open file  example.txt  ';
    }else{
    if (! ( $length  =  fwrite($fp, $content )  )   ){
    echo 'writing to the file failed';
    }else{
    echo 'Content wrote  successfully to the file';
    }
   fclose($fp);
   }
   }
  ?&gt; </pre>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/php-tutorials/php-file-functions/php-file-write-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax examples with php</title>
		<link>http://www.samplephpcodes.com/sample-php-codes/ajax/ajax-examples-with-php/</link>
		<comments>http://www.samplephpcodes.com/sample-php-codes/ajax/ajax-examples-with-php/#comments</comments>
		<pubDate>Sun, 18 Oct 2009 16:46:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[ajax as simple function call]]></category>
		<category><![CDATA[ajax drag and drop script]]></category>
		<category><![CDATA[ajax examples with php]]></category>
		<category><![CDATA[Ajax made easy]]></category>
		<category><![CDATA[ajax script demo]]></category>
		<category><![CDATA[ajax script download]]></category>
		<category><![CDATA[ajax tabs script]]></category>
		<category><![CDATA[auction php scripts]]></category>
		<category><![CDATA[dhtml ajax scripts]]></category>
		<category><![CDATA[free ajax scripts]]></category>
		<category><![CDATA[id of the dom element to be changed]]></category>
		<category><![CDATA[pass parameter to ajax call]]></category>

		<guid isPermaLink="false">http://samplephpcodes.com/?p=71</guid>
		<description><![CDATA[Ajax is a catchy name for a type of programming made popular in 2005 by Google and other big web developers. Ajax loosely stands for Asynchronous Javascript And XML, but that just sounds like techno jargon to many people. &#60;!-- AJAX CODE BY samplephpcodes.com makeGetRequest('file.php?uid=&#60;?php echo $fid; ?&#62;',result_div_id) --&#62; &#60;!-- ++++++++++++++++++++++++++++++++++++++++ --&#62; &#60;script language=&#34;javascript&#34;&#62; function [...]]]></description>
			<content:encoded><![CDATA[<p>Ajax is a catchy name for a type of programming made popular in 2005 by Google and other big web developers. Ajax loosely stands for Asynchronous Javascript And XML, but that just sounds like techno jargon to many people.</p>
<pre class="brush: php;">
&lt;!--
AJAX CODE BY samplephpcodes.com	

makeGetRequest('file.php?uid=&lt;?php echo $fid; ?&gt;',result_div_id)

--&gt;
&lt;!-- ++++++++++++++++++++++++++++++++++++++++ --&gt;

&lt;script language=&quot;javascript&quot;&gt;

function createRequestObject() {

    var tmpXmlHttpObject;

    if (window.XMLHttpRequest) { 

        // Mozilla, Safari would use this method ...

        tmpXmlHttpObject = new XMLHttpRequest();

    } else if (window.ActiveXObject) { 

        // IE would use this method ...

        tmpXmlHttpObject = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);

    }

    return tmpXmlHttpObject;

}

var http = createRequestObject();

var out;

function makeGetRequest(url,temp) {

   	out=temp;
	var val=Math.random();

	url=url+'&amp;sid='+val;
	http.open('get', url);

	http.onreadystatechange = processResponse;

	http.send(null);

}

function processResponse() {

     if(http.readyState == 4){

        var response = http.responseText;

	    document.getElementById(out).innerHTML = response;

       }

}

&lt;/script&gt;

&lt;!-- +++++++++++++++++++++++++++++++++++++++++++++++ --&gt;
</pre>
<p>After including the following code in the head part of the html page call the followin javascript function wereru need to call you ajax request</p>
<pre class="brush: php;">

makeGetRequest('file.php?uid=&lt;?php echo $fid; ?&gt;',result_div_id)
</pre>
<p>In the above Javascript code, we try three times to make our XMLHttpRequest object. Our first attempt:</p>
<p>    * ajaxRequest = new XMLHttpRequest();</p>
<p>is for the Opera 8.0+, Firefox and Safari browsers. If that fails we try two more times to make the correct object for an Internet Explorer browser with:</p>
<p>    * ajaxRequest = new ActiveXObject(&#8220;Msxml2.XMLHTTP&#8221;);<br />
    * ajaxRequest = new ActiveXObject(&#8220;Microsoft.XMLHTTP&#8221;);></p>
<p>If that doesn&#8217;t work, then they are using a very outdated browser that doesn&#8217;t support XMLHttpRequest, which also means it doesn&#8217;t support Ajax.</p>
<p>Most likely though, our variable ajaxRequest will now be set to whatever XMLHttpRequest standard the browser uses and we can start sending data to the server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.samplephpcodes.com/sample-php-codes/ajax/ajax-examples-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
