<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8859447625947777020</id><updated>2026-02-27T12:42:16.419-08:00</updated><category term="Php"/><category term="Learn Php Basics"/><category term="Installation Php"/><category term="Php Lessons"/><category term="Magic Methods in Php"/><category term="Php PDO"/><category term="Xampp"/><category term="Linux"/><category term="Configuration Php"/><category term="Php MVC(Model View Controller)"/><category term="Web Services"/><category term="PHP Editors"/><category term="Php4 vs Php5"/><title type='text'>All About PHP</title><subtitle type='html'>Learn php Tutorial, About php,Object Oriented Programing in Php,Php Code</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>68</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-2786866790255310994</id><published>2012-12-05T23:12:00.000-08:00</published><updated>2012-12-05T23:12:22.314-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php MVC(Model View Controller)"/><title type='text'>Understanding the Zend Framework Basix</title><content type='html'>What is the Zend Framework, exactly? The Zend Framework:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Is based on PHP&lt;/li&gt;
&lt;li&gt;Is object-oriented&lt;/li&gt;
&lt;li&gt;Uses the MVC paradigm&lt;/li&gt;
&lt;li&gt;Has open source contributors&lt;/li&gt;
&lt;li&gt;Has contributors who take responsibility for the fact that their code
                    is not the intellectual property of someone else&lt;/li&gt;
&lt;/ul&gt;
It also aims to make your programming life easier, not just in general by
                instituting the MVC pattern, but also for specific things you tend to do
                all the time, like access databases or output to a PDF file.&lt;br /&gt;
&lt;br /&gt;
Zend Framework components include:&lt;br /&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Controller&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This module provides the overall control for the application. It
                    translates requests into specific actions and makes sure they get
                    executed.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Db&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This is based on PHP Data Objects (PDO) and provides access to
                    databases in a generic way.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Feed&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This makes it easy to consume RSS and Atom feeds.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Filter&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This provides string-filtering functions, such as
                    &lt;code&gt;isEmail()&lt;/code&gt; and
                    &lt;code&gt;getAlpha()&lt;/code&gt;.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_InputFilter&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;To &lt;code&gt;Zend_Filter&lt;/code&gt;, this is designed to work
                    with arrays such as form inputs.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_HttpClient&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This enables you perform HTTP requests easily.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Json&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This enables you to easily translate PHP objects into JavaScript
                    Object Notation, and vice-versa.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Log&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This provides general-purpose logging functionality.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Mail&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This enables you to send text and multipart MIME email.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Mime&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This is used by &lt;code&gt;Zend_Mail&lt;/code&gt; to help decode
                    MIME messages.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Pdf&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This enables you to create new PDF documents, and load and edit
                    existing PDF documents.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Search&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This enables you to perform sophisticated searches on your own text.
                    For example, you can build a search engine that returns results based
                    on relevancy or other factors.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_Service&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;Contains several submodules that provide easy access to many popular
                    web service APIs, such as those provided by Amazon, Yahoo, Twitter,
                    and Flicker.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_View&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This handles the &lt;i&gt;view&lt;/i&gt; portion of the MVC pattern.&lt;/dd&gt;
            &lt;/dl&gt;
&lt;dl&gt;
&lt;dt&gt;&lt;b&gt;
                    &lt;b&gt;Zend_XmlRpc&lt;/b&gt;
                &lt;/b&gt;&lt;/dt&gt;
&lt;dd&gt;This enables you to easily create an XML-RPC server and client.&lt;/dd&gt;&lt;/dl&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/2786866790255310994/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/2786866790255310994' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/2786866790255310994'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/2786866790255310994'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/12/understanding-zend-framework-basix.html' title='Understanding the Zend Framework Basix'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-4494166888875031421</id><published>2012-11-06T22:33:00.002-08:00</published><updated>2012-11-06T22:33:38.621-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Configuration Php"/><title type='text'>.htaccess redirect url example</title><content type='html'>&lt;br/&gt;If I want to direct the non-www version of whhsupport.com to the www 
  version I would place the following code into my .htaccess file:
&lt;br /&gt;
&lt;pre&gt;RewriteEngine On
RewriteCond %{HTTP_HOST} ^whhsupport.com
RewriteRule (.*) &lt;a href=&quot;http://www.whhsupport.com/$1&quot;&gt;http://www.whhsupport.com/$1&lt;/a&gt; [R=301,L]&lt;/pre&gt;
&lt;br /&gt;
Conversely, if I want to direct the www version of whhsupport.com to
  the non-www version, I would enter the following code into my 
.htaccess  file:
&lt;br /&gt;
&lt;pre&gt;RewriteEngine on
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^www\.whhsupport\.com$ [NC]
RewriteRule ^(.*)$ &lt;a href=&quot;http://whhsupport.com/$1&quot;&gt;http://whhsupport.com/$1&lt;/a&gt; [R=301,L]&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/4494166888875031421/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/4494166888875031421' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/4494166888875031421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/4494166888875031421'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/11/htaccess-redirect-url-example.html' title='.htaccess redirect url example'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-8645191604726479219</id><published>2012-10-16T05:18:00.002-07:00</published><updated>2012-10-16T05:18:24.960-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php Lessons"/><title type='text'>Mysql Fulltext search Video Example</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;415&quot; src=&quot;http://www.youtube.com/embed/d--v0NhjIfc&quot; width=&quot;660&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/8645191604726479219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/8645191604726479219' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/8645191604726479219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/8645191604726479219'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/10/mysql-fulltext-search-video-example.html' title='Mysql Fulltext search Video Example'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/d--v0NhjIfc/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-7081972002565544039</id><published>2012-10-10T05:10:00.000-07:00</published><updated>2012-10-10T05:10:54.925-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php"/><title type='text'>Php -  Regular Expressions</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Regular expressions are nothing more than a sequence or pattern of characters itself. They provide the foundation for pattern-matching functionality. &lt;br /&gt;
Using regular expression you can search a particular string inside a another string, you can replace one string by another string and you can split a string into many chunks.&lt;br /&gt;
PHP offers functions specific to two sets of regular expression functions, each corresponding to a certain type of regular expression. You can use any of them based on your comfort.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;POSIX Regular Expressions&lt;/li&gt;
&lt;li&gt;PERL Style  Regular Expressions&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
POSIX Regular Expressions:&lt;/h2&gt;
The structure of a POSIX regular expression is not dissimilar to that of a typical arithmetic expression: various elements (operators) are combined to form more complex expressions.&lt;br /&gt;
The simplest regular expression is one that matches a single character, such as g, inside strings such as g, haggle, or bag.&lt;br /&gt;
Lets give explaination for few concepts being used in POSIX regular expression. After that we will introduce you wih regular expression related functions.&lt;br /&gt;
&lt;h3&gt;
Brackets&lt;/h3&gt;
Brackets ([]) have a special meaning when used in the context of regular expressions. They are used to find a range of characters.&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;src&quot; style=&quot;width: 100%px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th width=&quot;10%&quot;&gt;Expression&lt;/th&gt;&lt;th width=&quot;90%&quot;&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;[0-9]
&lt;/td&gt;
&lt;td&gt;It matches any decimal digit from 0 through 9.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;[a-z]
&lt;/td&gt;
&lt;td&gt;It matches any character from lowercase a through lowercase z.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;[A-Z]
&lt;/td&gt;
&lt;td&gt;It matches any character from uppercase A through uppercase Z.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;[a-Z]
&lt;/td&gt;
&lt;td&gt;It matches any character from lowercase a through uppercase Z.
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
The ranges shown above are general; you could also use the range [0-3] to match any decimal digit ranging from 0 through 3, or the range [b-v] to match any lowercase character ranging from b through v.&lt;br /&gt;
&lt;h3&gt;
Quantifiers:&lt;/h3&gt;
The frequency or position of bracketed character sequences and single characters can be denoted by a special character. Each pecial character having a specific connotation. The +, *, ?, {int. range}, and $ flags all follow a character sequence.&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;src&quot; style=&quot;width: 100%px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th width=&quot;10%&quot;&gt;Expression&lt;/th&gt;&lt;th width=&quot;90%&quot;&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p+
&lt;/td&gt;
&lt;td&gt;It matches any string containing at least one p.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p*
&lt;/td&gt;
&lt;td&gt;It matches any string containing zero or more p&#39;s.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p?
&lt;/td&gt;
&lt;td&gt;It matches any string containing zero or more p&#39;s. This is just an alternative way to use p*.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p{&lt;b&gt;N&lt;/b&gt;}
&lt;/td&gt;
&lt;td&gt;It matches any string containing a sequence of &lt;b&gt;N&lt;/b&gt; p&#39;s
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p{2,3}
&lt;/td&gt;
&lt;td&gt;It matches any string containing a sequence of two or three p&#39;s.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p{2, }
&lt;/td&gt;
&lt;td&gt;It matches any string containing a sequence of at least two p&#39;s.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p$
&lt;/td&gt;
&lt;td&gt;It  matches any string with p at the end of it.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;b&gt;^&lt;/b&gt;p
&lt;/td&gt;
&lt;td&gt;It matches any string with p at the beginning of it.
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3&gt;
Examples:&lt;/h3&gt;
Following examples will clear your concepts about matching chracters.&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;src&quot; style=&quot;width: 100%px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th width=&quot;10%&quot;&gt;Expression&lt;/th&gt;&lt;th width=&quot;90%&quot;&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;[^a-zA-Z]
&lt;/td&gt;
&lt;td&gt;It matches any string not containing any of the characters ranging from a through z and A through Z.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p.p
&lt;/td&gt;
&lt;td&gt;It matches any string containing p, followed by any character, in turn followed by another p.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;^.{2}$
&lt;/td&gt;
&lt;td&gt;It matches any string containing exactly two characters.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&amp;lt;b&amp;gt;(.*)&amp;lt;/b&amp;gt;
&lt;/td&gt;
&lt;td&gt;It matches any string enclosed within &amp;lt;b&amp;gt; and &amp;lt;/b&amp;gt;.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;p(hp)*
&lt;/td&gt;
&lt;td&gt;It matches any string containing a p followed by zero or more instances of the sequence hp.
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3&gt;
Predefined Character Ranges&lt;/h3&gt;
For your programming convenience several predefined character ranges, also known as character classes, are available. Character classes specify an entire range of characters, for example, the alphabet or an integer set:&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;5&quot; cellspacing=&quot;0&quot; class=&quot;src&quot; style=&quot;width: 100%px;&quot;&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th width=&quot;10%&quot;&gt;Expression&lt;/th&gt;&lt;th width=&quot;90%&quot;&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;[[:alpha:]]
&lt;/td&gt;
&lt;td&gt;It matches any string containing alphabetic characters aA through zZ.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;[[:digit:]]
&lt;/td&gt;
&lt;td&gt;It matches any string containing numerical digits 0 through 9.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;[[:alnum:]]
&lt;/td&gt;
&lt;td&gt;It matches any string containing alphanumeric characters aA through zZ and 0 through 9.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;[[:space:]]
&lt;/td&gt;
&lt;td&gt;It matches any string containing a space.
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2&gt;
&lt;/h2&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/7081972002565544039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/7081972002565544039' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/7081972002565544039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/7081972002565544039'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/10/php-regular-expressions.html' title='Php -  Regular Expressions'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-9193370618220971987</id><published>2012-09-19T22:43:00.000-07:00</published><updated>2012-09-19T22:45:20.036-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php Lessons"/><title type='text'>Php  Custom function - Difference between two dates,time and date  </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The function presented in this page, &lt;b&gt;CalculateDiff()&lt;/b&gt;, can be used &lt;b&gt;to get the difference between 2 dates, 
 time and date&lt;/b&gt; .&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;This function takes two parameters&lt;/b&gt;: the date1 and date2.
It can be used various date / time formats: Unix Timestamp, or a string&lt;br /&gt;
&lt;br /&gt;
Function that returns the difference between two date-time
Returns an array containing a string with a textual reprezentation of the difference,
and separately: &lt;b&gt;the days&lt;/b&gt;, &lt;b&gt;hours&lt;/b&gt;, &lt;b&gt;minutes&lt;/b&gt;, &lt;b&gt;seconds&lt;/b&gt;, &lt;b&gt;total&lt;/b&gt; &lt;b&gt;hours&lt;/b&gt;, &lt;b&gt;total minutes&lt;/b&gt;, and &lt;b&gt;total seconds&lt;/b&gt;.
&lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;CalculateDiff&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date1&lt;/span&gt;, &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date2&lt;/span&gt;) {
      &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; sets to use $date1 and $date2 as Unix Timestamp&lt;/span&gt;
    &lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; (!&lt;span class=&quot;ST0&quot;&gt;is_int&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date1&lt;/span&gt;))
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date1&lt;/span&gt; = &lt;span class=&quot;ST0&quot;&gt;strtotime&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date1&lt;/span&gt;);
    &lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; (!&lt;span class=&quot;ST0&quot;&gt;is_int&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date2&lt;/span&gt;))
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date2&lt;/span&gt; = &lt;span class=&quot;ST0&quot;&gt;strtotime&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date2&lt;/span&gt;);

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; if the difference is negative, the hours are from different days, and adds 1 day (in sec.)&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$diff&lt;/span&gt; = (&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date2&lt;/span&gt; &amp;gt;= &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date1&lt;/span&gt;) ? &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date2&lt;/span&gt; - &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date1&lt;/span&gt; : &lt;span class=&quot;number&quot;&gt;86400&lt;/span&gt; + &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date2&lt;/span&gt; - &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date1&lt;/span&gt;;

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; define the number of days, hours, minutes and seconds in difference&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$d&lt;/span&gt; = &lt;span class=&quot;ST0&quot;&gt;floor&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$diff&lt;/span&gt; / &lt;span class=&quot;number&quot;&gt;86400&lt;/span&gt;);
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$h&lt;/span&gt; = &lt;span class=&quot;ST0&quot;&gt;floor&lt;/span&gt;(&lt;span class=&quot;ST0&quot;&gt;abs&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$diff&lt;/span&gt; - &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$d&lt;/span&gt; * &lt;span class=&quot;number&quot;&gt;86400&lt;/span&gt;) / &lt;span class=&quot;number&quot;&gt;3600&lt;/span&gt;);
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$m&lt;/span&gt; = &lt;span class=&quot;ST0&quot;&gt;floor&lt;/span&gt;(&lt;span class=&quot;ST0&quot;&gt;abs&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$diff&lt;/span&gt; - &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$d&lt;/span&gt; * &lt;span class=&quot;number&quot;&gt;86400&lt;/span&gt; - &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$h&lt;/span&gt; * &lt;span class=&quot;number&quot;&gt;3600&lt;/span&gt;) / &lt;span class=&quot;number&quot;&gt;60&lt;/span&gt;);
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$s&lt;/span&gt; = &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$diff&lt;/span&gt; % &lt;span class=&quot;number&quot;&gt;60&lt;/span&gt;;

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; sets the words, singular or plural&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dstr&lt;/span&gt; = (&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$d&lt;/span&gt; == &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;) ? &lt;span class=&quot;string&quot;&gt;&#39; day &#39;&lt;/span&gt; : &lt;span class=&quot;string&quot;&gt;&#39; days &#39;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$hstr&lt;/span&gt; = (&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$h&lt;/span&gt; == &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;) ? &lt;span class=&quot;string&quot;&gt;&#39; hour &#39;&lt;/span&gt; : &lt;span class=&quot;string&quot;&gt;&#39; hours &#39;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$mstr&lt;/span&gt; = (&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$m&lt;/span&gt; == &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;) ? &lt;span class=&quot;string&quot;&gt;&#39; minute &#39;&lt;/span&gt; : &lt;span class=&quot;string&quot;&gt;&#39; minutes &#39;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sstr&lt;/span&gt; = (&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$s&lt;/span&gt; == &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;) ? &lt;span class=&quot;string&quot;&gt;&#39; second &#39;&lt;/span&gt; : &lt;span class=&quot;string&quot;&gt;&#39; seconds &#39;&lt;/span&gt;;

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; setings for the string added in textual reprezentation of the difference&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sdiff_d&lt;/span&gt; = (&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$d&lt;/span&gt; != &lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;) ? &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$d&lt;/span&gt; . &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dstr&lt;/span&gt; : &lt;span class=&quot;string&quot;&gt;&#39;&#39;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sdiff_h&lt;/span&gt; = (&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$h&lt;/span&gt; != &lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;) ? &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$h&lt;/span&gt; . &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$hstr&lt;/span&gt; : &lt;span class=&quot;string&quot;&gt;&#39;&#39;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sdiff_m&lt;/span&gt; = (&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$m&lt;/span&gt; != &lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;) ? &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$m&lt;/span&gt; . &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$mstr&lt;/span&gt; : &lt;span class=&quot;string&quot;&gt;&#39;&#39;&lt;/span&gt;;

    &lt;span class=&quot;keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;keyword&quot;&gt;array&lt;/span&gt;(
        &lt;span class=&quot;string&quot;&gt;&#39;diff&#39;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sdiff_d&lt;/span&gt; . &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sdiff_h&lt;/span&gt; . &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sdiff_m&lt;/span&gt; . &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$s&lt;/span&gt; . &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sstr&lt;/span&gt;,
        &lt;span class=&quot;string&quot;&gt;&#39;days&#39;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$d&lt;/span&gt;,
        &lt;span class=&quot;string&quot;&gt;&#39;hours&#39;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$h&lt;/span&gt;,
        &lt;span class=&quot;string&quot;&gt;&#39;min&#39;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$m&lt;/span&gt;,
        &lt;span class=&quot;string&quot;&gt;&#39;sec&#39;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$s&lt;/span&gt;,
        &lt;span class=&quot;string&quot;&gt;&#39;totalhours&#39;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;ST0&quot;&gt;floor&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$diff&lt;/span&gt; / &lt;span class=&quot;number&quot;&gt;3600&lt;/span&gt;),
        &lt;span class=&quot;string&quot;&gt;&#39;totalmin&#39;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;ST0&quot;&gt;floor&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$diff&lt;/span&gt; / &lt;span class=&quot;number&quot;&gt;60&lt;/span&gt;),
        &lt;span class=&quot;string&quot;&gt;&#39;totalsec&#39;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$diff&lt;/span&gt;
    );
}
&lt;span class=&quot;ST0&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Examples of CalculateDiff() function usage, with different date-time formats:
&lt;/h2&gt;
&lt;pre&gt; &lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
        &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; difference between 2 times (in hours:min:sec)&lt;/span&gt;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;rs1&lt;/span&gt; = &lt;span class=&quot;ST0&quot;&gt;CalculateDiff&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&#39;8:35:6&#39;&lt;/span&gt;, &lt;span class=&quot;string&quot;&gt;&#39;8:55:34&#39;&lt;/span&gt;);         
        &lt;span class=&quot;ST0&quot;&gt;var_export&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;rs1&lt;/span&gt;);
&lt;span class=&quot;ST0&quot;&gt;    ?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;b&gt;Result:&lt;/b&gt;&lt;br /&gt;
array (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;diff&#39; =&amp;gt; &#39;20 minutes 28 seconds &#39;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;days&#39; =&amp;gt; 0, &#39;hours&#39; =&amp;gt; 0, &#39;min&#39; =&amp;gt; 20, &#39;sec&#39; =&amp;gt; 28,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;totalhours&#39; =&amp;gt; 0, &#39;totalmin&#39; =&amp;gt; 20, &#39;totalsec&#39; =&amp;gt; 1228&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt; &lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
        // difference between a previous date-time and now
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;rs2&lt;/span&gt; = &lt;span class=&quot;ST0&quot;&gt;CalculateDiff&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&#39;07/19/2012 14:10:00&#39;, &#39;now&#39;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&lt;/span&gt;);         
        &lt;span class=&quot;ST0&quot;&gt;var_export&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;rs2&lt;/span&gt;);
&lt;span class=&quot;ST0&quot;&gt;    ?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;b&gt;Result:&lt;/b&gt;&lt;br /&gt;
array (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;diff&#39; =&amp;gt; &#39;61 days 16 hours 9 minutes 20 seconds &#39;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;days&#39; =&amp;gt; 72, &#39;hours&#39; =&amp;gt; 16, &#39;min&#39; =&amp;gt; 9, &#39;sec&#39; =&amp;gt; 20,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;totalhours&#39; =&amp;gt; 1744, &#39;totalmin&#39; =&amp;gt; 104649, &#39;totalsec&#39; =&amp;gt; 6278960&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt; &lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
        &lt;span class=&quot;comment&quot;&gt;// difference between 2 date-times&lt;/span&gt;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;rs3&lt;/span&gt; = &lt;span class=&quot;ST0&quot;&gt;CalculateDiff&lt;/span&gt;(&#39;25 August 2012 14:10:00&#39;, &#39;18-09-2012 08:25:00&#39;);         
        &lt;span class=&quot;ST0&quot;&gt;var_export&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;rs3&lt;/span&gt;);
&lt;span class=&quot;ST0&quot;&gt;    ?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;b&gt;Result:&lt;/b&gt;&lt;br /&gt;
array (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;diff&#39; =&amp;gt; &#39;23 days 18 hours 15 minutes 0 seconds &#39;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;days&#39; =&amp;gt; 23, &#39;hours&#39; =&amp;gt; 18, &#39;min&#39; =&amp;gt; 15, &#39;sec&#39; =&amp;gt; 0,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;totalhours&#39; =&amp;gt; 570, &#39;totalmin&#39; =&amp;gt; 34215, &#39;totalsec&#39; =&amp;gt; 2052900&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt; &lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
        &lt;span class=&quot;comment&quot;&gt;// difference between 2 date-time, with Timestamp&lt;/span&gt;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;rs4&lt;/span&gt; = &lt;span class=&quot;ST0&quot;&gt;CalculateDiff&lt;/span&gt;(1348012438, 1348029429);         
        &lt;span class=&quot;ST0&quot;&gt;var_export&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;rs4&lt;/span&gt;);
&lt;span class=&quot;ST0&quot;&gt;    ?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;b&gt;Result:&lt;/b&gt;&lt;br /&gt;
array (&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;diff&#39; =&amp;gt; &#39;4 hours 43 minutes 11 seconds &#39;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;days&#39; =&amp;gt; 0, &#39;hours&#39; =&amp;gt; 4, &#39;min&#39; =&amp;gt; 43, &#39;sec&#39; =&amp;gt; 11,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;totalhours&#39; =&amp;gt; 4, &#39;totalmin&#39; =&amp;gt; 283, &#39;totalsec&#39; =&amp;gt; 16991&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/9193370618220971987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/9193370618220971987' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/9193370618220971987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/9193370618220971987'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-custom-function-difference-between.html' title='Php  Custom function - Difference between two dates,time and date  '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-1475882225146757760</id><published>2012-09-19T00:07:00.000-07:00</published><updated>2012-09-19T00:07:33.084-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Installation Php"/><category scheme="http://www.blogger.com/atom/ns#" term="Php Lessons"/><title type='text'>Install Zend Framework on Ubuntu Linux</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Zend Framework on Ubuntu Linux
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;425&quot; src=&quot;http://www.youtube.com/embed/O5WQw6WiqFc&quot; width=&quot;599&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/1475882225146757760/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/1475882225146757760' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/1475882225146757760'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/1475882225146757760'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/install-zend-framework-on-ubuntu-linux.html' title='Install Zend Framework on Ubuntu Linux'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/O5WQw6WiqFc/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-4278785392939903212</id><published>2012-09-18T23:34:00.000-07:00</published><updated>2012-09-18T23:34:11.973-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Installation Php"/><category scheme="http://www.blogger.com/atom/ns#" term="Php Lessons"/><title type='text'>Install Zend Framework in Mac OS</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Installing zend Framework in Mac Os
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;400&quot; mozallowfullscreen=&quot;mozallowfullscreen&quot; src=&quot;http://player.vimeo.com/video/4785098&quot; webkitallowfullscreen=&quot;webkitallowfullscreen&quot; width=&quot;599&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/4278785392939903212/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/4278785392939903212' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/4278785392939903212'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/4278785392939903212'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/install-zend-framework-in-mac-os.html' title='Install Zend Framework in Mac OS'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-6656327675299927180</id><published>2012-09-14T23:57:00.000-07:00</published><updated>2012-10-11T02:41:40.027-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php Lessons"/><title type='text'>Mysql Full-Text Search</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The Full text Search will produce results faster than Simply using “OR” in sql query. 
&lt;br /&gt;
&lt;h2 style=&quot;font-size: 18px;&quot;&gt;
Mysql Full-Text Search Basics&lt;/h2&gt;
For start &lt;i&gt;&lt;b&gt;using mysql full text search&lt;/b&gt; for multi-word queries&lt;/i&gt; we need to understand its basics.Firstly it can’t be implemented on Mysql innoDB storage engine tables,So the First thing we must do is &lt;b&gt;convert our innoDB table to MyISam Engine&lt;/b&gt;,which is quite easy can be done using phpmyadmin under the operations tab . &lt;br /&gt;
&lt;div class=&quot;wp-caption aligncenter&quot; id=&quot;attachment_1051&quot; style=&quot;width: 569px;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitg3tiRsSP1Pb0iuM1KgsFsDcLY9wTllwOl_FPa5u902cryLHOWfG684MoRPdOxAVA3-GTOuqjJHEzClZD_C5tLJcJkXr23xO9x8POH4bbkSWQIMl7ulQot4qXbI0AMrEFS07qTFORFlM/s1600/fulltext-search-myisam.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;414&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitg3tiRsSP1Pb0iuM1KgsFsDcLY9wTllwOl_FPa5u902cryLHOWfG684MoRPdOxAVA3-GTOuqjJHEzClZD_C5tLJcJkXr23xO9x8POH4bbkSWQIMl7ulQot4qXbI0AMrEFS07qTFORFlM/s640/fulltext-search-myisam.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;a href=&quot;http://www.designaeon.com/wp-content/uploads/2012/05/fulltext-search-myisam.jpg&quot;&gt;&lt;br /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;div class=&quot;wp-caption-text&quot;&gt;
Change Storage Engine to MyISAM&lt;/div&gt;
&lt;/div&gt;
After we have our tables on MyISAM storage engine we just need to &lt;b&gt;add full text index to our selected columns&lt;/b&gt; on the desired table.Which is again can be done using PHPmy admin or Use the Query below to &lt;b&gt;add Full Text INDEX To our Tables&lt;/b&gt;.The code Below will add&lt;b&gt; Full text index&lt;/b&gt; to&amp;nbsp; title and Description.columns&lt;br /&gt;
&lt;div class=&quot;jbox gray&quot;&gt;
&lt;div class=&quot;jbox-title gray&quot;&gt;
Add Full text Index to Table columns&lt;/div&gt;
&lt;div class=&quot;jbox-content&quot;&gt;
&lt;pre&gt;ALTER TABLE inventory ADD FULLTEXT(title, description)&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
or using phpmyadmin as below.&lt;br /&gt;
&lt;h3 style=&quot;font-size: 16px;&quot;&gt;
&amp;nbsp;Mysql Full Text Index on Single Column:&lt;/h3&gt;
&lt;div class=&quot;wp-caption aligncenter&quot; id=&quot;attachment_1056&quot; style=&quot;width: 655px;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDe2_s97j0Qma_iNQoY6Lr3wvaix77drNjv1i0cb_y7x87enIV8zF6seij4KGagj27Q3ZFNtmeOM0_1AtBmHyiGzFeHgLAXnYUrlUI1e0_VGmK9y2PXe8z1UIhN4_LYnZcbIRpaJKijIo/s1600/full-text-phpmyadmin.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;140&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjDe2_s97j0Qma_iNQoY6Lr3wvaix77drNjv1i0cb_y7x87enIV8zF6seij4KGagj27Q3ZFNtmeOM0_1AtBmHyiGzFeHgLAXnYUrlUI1e0_VGmK9y2PXe8z1UIhN4_LYnZcbIRpaJKijIo/s640/full-text-phpmyadmin.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;a href=&quot;http://www.designaeon.com/wp-content/uploads/2012/05/full-text-phpmyadmin.jpg&quot;&gt;&lt;br /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;div class=&quot;wp-caption-text&quot;&gt;
adding full text Index on Single column using PHPmyadmin&lt;/div&gt;
&lt;/div&gt;
&lt;h3 style=&quot;font-size: 16px;&quot;&gt;
Mysql Full Text Index on Multiple Column:&lt;/h3&gt;
&lt;div class=&quot;wp-caption aligncenter&quot; id=&quot;attachment_1068&quot; style=&quot;width: 658px;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXZF488LyEopx2sbm75RsiUaaiQeRzk3V8tntlbwgfzsuNu76OiHp7KTR01f3v1Hs9p7uqPk7TTJMlRTF8yCpXMoixfcu3o7DaFNYUMFpkIctwrgD9JuP8Uw8pm4JL8tsJtBJeOVPbgTQ/s1600/multiple-clumn-full-text-index-pma.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;173&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhXZF488LyEopx2sbm75RsiUaaiQeRzk3V8tntlbwgfzsuNu76OiHp7KTR01f3v1Hs9p7uqPk7TTJMlRTF8yCpXMoixfcu3o7DaFNYUMFpkIctwrgD9JuP8Uw8pm4JL8tsJtBJeOVPbgTQ/s640/multiple-clumn-full-text-index-pma.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;a href=&quot;http://www.designaeon.com/wp-content/uploads/2012/05/multiple-clumn-full-text-index-pma.jpg&quot;&gt;&lt;br /&gt;&lt;/a&gt;
&lt;br /&gt;
&lt;div class=&quot;wp-caption-text&quot;&gt;
Add Full text INDEX On multiple Columns&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;jbox red&quot;&gt;
&lt;div class=&quot;jbox-title red&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;jbox-content&quot;&gt;
&lt;b&gt;Note&lt;/b&gt;:&lt;span style=&quot;color: red;&quot;&gt;&lt;b&gt;The FULL text index on single column and pair of column is differet things&lt;/b&gt;&lt;/span&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;font-size: 16px; text-align: left;&quot;&gt;
Usage MySql Full Text Search for Multiword String:&lt;/h2&gt;
So Now Our table Are ready for Full text Search as we have provided full index.Now to search for any word say :we wana search “Sujal &amp;nbsp;Shah” then we’ll tyep Query as:&lt;br /&gt;
&lt;div class=&quot;jbox gray&quot;&gt;
&lt;div class=&quot;jbox-title gray&quot;&gt;
Searching using Full text Index.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;jbox-content&quot;&gt;
&lt;pre&gt;SELECT *, MATCH(title, description) AGAINST (&#39;Sujal Shah boy&#39;) AS artist
FROM artist_listing
ORDER BY artist DESC&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
The above query will match two columns title and description for Words “Sujal Shah boy” .For that to happen we need to have a multiple column&lt;i&gt; Full text &amp;nbsp;index&lt;/i&gt;, which i just told to how to create above.&lt;br /&gt;
&lt;h3 style=&quot;font-size: 18px;&quot;&gt;
BOOLEAN MODE Operators in MySQL Full Text Search :&lt;/h3&gt;
If We Use &lt;b&gt;BOOLEAN FULL TEXT SEARCHE&lt;/b&gt; which means we’ll add boolean mode and we will have some useful operators available to us if we use Boolean mode.&lt;br /&gt;
&lt;br /&gt;
As we just seen the Query “&lt;b&gt;Sujal Shah boy&lt;/b&gt;” There is no Operator in between &amp;nbsp;.We could use operators for&amp;nbsp;further&amp;nbsp;refinement or as per needs, only if we use&lt;b&gt; IN BOOLEAN MODE modifier&lt;/b&gt;. In Query “&lt;b&gt;Sujal Shah boy&lt;/b&gt;” having no operator means Simply “OR” in &lt;b&gt;&lt;i&gt;boolean mode full text search&lt;/i&gt;&lt;/b&gt;.The &lt;b&gt;Full text Search&lt;/b&gt; will Use OR &amp;nbsp;in boolean mode .which means Will find all the rows having any one of those words.&lt;br /&gt;
&lt;div class=&quot;jbox gray&quot;&gt;
&lt;div class=&quot;jbox-title gray&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;Example&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&quot;jbox-content&quot;&gt;
&lt;pre&gt;SELECT *, MATCH(title, description) AGAINST (&#39;+Sujal -Shah +boy&#39; IN BOOLEAN MODE) AS artist
FROM artist_listing
ORDER BY artist DESC&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;b&gt;+&lt;/b&gt;&amp;nbsp;means&amp;nbsp;&lt;b&gt;AND&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;-&lt;/b&gt;&amp;nbsp;means&amp;nbsp;&lt;b&gt;NOT&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;[no operator]&lt;/b&gt;&amp;nbsp;means&amp;nbsp;&lt;b&gt;OR&lt;/b&gt;&lt;br /&gt;
Here i have few examples using Mysql Full text search with operators:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;+Sujal +Shah +boy&lt;/b&gt;:Will find only rows having all three words&lt;/li&gt;
&lt;li&gt;&lt;b&gt;+&lt;/b&gt;&lt;b&gt;&lt;b&gt;Sujal &lt;/b&gt;-Shah&lt;/b&gt; : will find rows that contain Sujal but not Shah&lt;/li&gt;
&lt;li&gt;&lt;b&gt;+Sujal Shah&lt;/b&gt; :will find rows that must contain Sujal,&amp;nbsp;but rank rows higher if they also contain “Shah”.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;+Sujal ~Shah&lt;/b&gt; :Fetch&amp;nbsp;rows that must have the word “Sujal”, but if the row also have the word “Shah”, rate it lower than if row does not.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;‘+Sujal +(&amp;gt;Shah &amp;lt;boy)’ :&lt;/b&gt;Get the rows that contain the words “Sujal” and “Shah”, or “boy” and “boy” (in any order), but rank “Sujal Shah” high than “Sujal boy”.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;h3 style=&quot;font-size: 16px;&quot;&gt;
&amp;nbsp;MySQL FULL TEXT SEARCH LIMITS :&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Full text search&lt;/b&gt; can Only be used with &lt;b&gt;MyIsam &lt;/b&gt;TABLES.&lt;/li&gt;
&lt;li&gt;For&lt;b&gt; &lt;i&gt;Full text Search&lt;/i&gt;&lt;/b&gt; to to work, there must be Full text indexes defined otherwise SQL will throw error and &lt;b&gt;Full text search&lt;/b&gt; will not work.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/6656327675299927180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/6656327675299927180' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/6656327675299927180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/6656327675299927180'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/mysql-full-text-search.html' title='Mysql Full-Text Search'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEitg3tiRsSP1Pb0iuM1KgsFsDcLY9wTllwOl_FPa5u902cryLHOWfG684MoRPdOxAVA3-GTOuqjJHEzClZD_C5tLJcJkXr23xO9x8POH4bbkSWQIMl7ulQot4qXbI0AMrEFS07qTFORFlM/s72-c/fulltext-search-myisam.jpg" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-820291963055305155</id><published>2012-09-14T04:01:00.000-07:00</published><updated>2012-09-14T04:16:52.840-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php Lessons"/><title type='text'>Php Date difference - Php Datetime object </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;

&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: large; font-weight: normal;&quot;&gt;&lt;b&gt;Example &lt;/b&gt;: add and diff method of Datetime object&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;
Here in below example &lt;b&gt;DateInterval object&lt;/b&gt; has the argument like &lt;b&gt;P&lt;span style=&quot;color: #cc0000;&quot;&gt;01Y&lt;/span&gt;&lt;span style=&quot;color: #351c75;&quot;&gt;01M&lt;/span&gt;&lt;span style=&quot;color: purple;&quot;&gt;10D&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
Here the &lt;b&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;01Y &lt;/span&gt;&lt;/b&gt;indicates&lt;b&gt; 1 year&lt;/b&gt;&lt;br /&gt;
Here the &lt;b&gt;&lt;span style=&quot;color: #351c75;&quot;&gt;01M &lt;/span&gt;&lt;/b&gt;indicates &lt;b&gt;1 month&lt;/b&gt;&lt;br /&gt;
Here the &lt;b&gt;&lt;span style=&quot;color: purple;&quot;&gt;10D &lt;/span&gt;&lt;/b&gt;indicates &lt;b&gt;10 days
&lt;/b&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;

    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$givendate&lt;/span&gt;=&lt;span class=&quot;string&quot;&gt;&#39;2001-01-01&#39;&lt;/span&gt;;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;add one year one month and ten days to given date&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;DateTime&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$givendate&lt;/span&gt;);
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;add&lt;/span&gt;(&lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;DateInterval&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&#39;P01Y01M10D&#39;&lt;/span&gt;));
    &lt;span class=&quot;keyword&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;format&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&#39;Y-m-d&#39;&lt;/span&gt;) . &lt;span class=&quot;string&quot;&gt;&quot;\n&quot;&lt;/span&gt;;

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;remove one year one month and ten days to given date&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;DateTime&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$givendate&lt;/span&gt;);
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;diff&lt;/span&gt;(&lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;DateInterval&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&#39;P01Y01M10D&#39;&lt;/span&gt;));
    &lt;span class=&quot;keyword&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$date&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;format&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&#39;Y-m-d&#39;&lt;/span&gt;) . &lt;span class=&quot;string&quot;&gt;&quot;\n&quot;&lt;/span&gt;;

&lt;span class=&quot;ST0&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;/pre&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
2002-02-11&lt;br /&gt;
2001-01-01 &lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-size: large; font-weight: normal;&quot;&gt;
&lt;b&gt;Example &lt;/b&gt;: Calculate Age of a Person using Datetime object&lt;/span&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;Php Date difference - Php Datetime object &lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$birthday&lt;/span&gt;=&lt;span class=&quot;string&quot;&gt;&quot;1984-10-18&quot;&lt;/span&gt;;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;creating object for birthday&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$birthday&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST1&quot;&gt;DateTime&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$birthday&lt;/span&gt;);
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;createing object for current date&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$currentdate&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST1&quot;&gt;DateTime&lt;/span&gt;();
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;calculate age using php Datetime object method&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST2&quot;&gt;age&lt;/span&gt;=&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$currentdate&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;diff&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$birthday&lt;/span&gt;);
    &lt;span class=&quot;ST1&quot;&gt;print_r&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST2&quot;&gt;age&lt;/span&gt;);

&lt;span class=&quot;ST1&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;Output:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;DateInterval Object&lt;/b&gt; (
&amp;nbsp;[&lt;b&gt;y&lt;/b&gt;] =&amp;gt; 27 &lt;br /&gt;
&amp;nbsp;[&lt;b&gt;m&lt;/b&gt;] =&amp;gt; 10 &lt;br /&gt;
&amp;nbsp;[&lt;b&gt;d&lt;/b&gt;] =&amp;gt; 27 &lt;br /&gt;
&amp;nbsp;[&lt;b&gt;h&lt;/b&gt;] =&amp;gt; 12 &lt;br /&gt;
&amp;nbsp;[&lt;b&gt;i&lt;/b&gt;] =&amp;gt; 38 &lt;br /&gt;
&amp;nbsp;[&lt;b&gt;s&lt;/b&gt;] =&amp;gt; 43 &lt;br /&gt;
&amp;nbsp;[&lt;b&gt;invert&lt;/b&gt;] =&amp;gt; 1 &lt;br /&gt;
&amp;nbsp;[&lt;b&gt;days&lt;/b&gt;] =&amp;gt; 10193 &lt;br /&gt;
)
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/820291963055305155/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/820291963055305155' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/820291963055305155'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/820291963055305155'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-date-difference-php-datetime-object.html' title='Php Date difference - Php Datetime object '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-6221979038521214741</id><published>2012-09-12T22:12:00.000-07:00</published><updated>2012-09-12T22:22:05.397-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php PDO"/><title type='text'>Php Pdo Exception Handling - Error mode in Php Pdo</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
PDO has 3 types error handling strategies,in php application development.
 &lt;br /&gt;
&lt;ul&gt;
&lt;li&gt; 
       &lt;b&gt;PDO::ERRMODE_SILENT&lt;/b&gt;&lt;/li&gt;
PDO will simply set the error code by default&amp;nbsp;
     to inspect using the  &lt;b&gt;&lt;span class=&quot;function&quot;&gt;PDO::errorCode()&lt;/span&gt;&lt;/b&gt; and
      &lt;b&gt;&lt;span class=&quot;function&quot;&gt;PDO::errorInfo()&lt;/span&gt;&lt;/b&gt; on both&amp;nbsp; database objects and statements; if the error resulted from a call on a
     statement object, you should use the
      &lt;b&gt;&lt;span class=&quot;function&quot;&gt;PDOStatement::errorCode()&lt;/span&gt;&lt;/b&gt; or
      &lt;b&gt;&lt;span class=&quot;function&quot;&gt;PDOStatement::errorInfo(&lt;/span&gt;&lt;/b&gt;
     method on that object. If the error resulted from a call on the
     database object, we should use those methods on the database object.&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;
   &lt;b&gt;PDO::ERRMODE_WARNING&lt;/b&gt;&lt;/li&gt;
PDO will show a traditional WARNING message if we use &lt;b&gt;ERRMODE_WARNING&lt;/b&gt; . This setting is useful while debugging/testing the code, if we want to see what problems occurred without disturbing the application.This will show errorcode also in warning. &lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;
   &lt;b&gt;PDO::ERRMODE_EXCEPTION&lt;/b&gt;&lt;/li&gt;
PDO will throw a
     PDO Exception
     and set its properties to reflect the error code and error
     information. This setting is while debugging the code, as it will
     effectively point to the error very
     quickly in the code
     (Transactions are automatically roll back if the exception occurs).
     &amp;nbsp;&lt;/ul&gt;
&lt;ul&gt;Exception mode is also usefult o structure error
     handling clearly than with normal PHP warnings and errors.&lt;/ul&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
PDO Hanling Exception Example 
&lt;/h2&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$host&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;mysql:dbname=testdb;host=localhost&#39;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$username&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;root&#39;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$password&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;&#39;&lt;/span&gt;;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;try catch block for handling pdo exception&lt;/span&gt;
    &lt;span class=&quot;keyword&quot;&gt;try&lt;/span&gt; {
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$pdoObj&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;PDO&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$host&lt;/span&gt;, &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$username&lt;/span&gt;, &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$password&lt;/span&gt;);
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$pdoObj&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;setAttribute&lt;/span&gt;(&lt;span class=&quot;ST0&quot;&gt;PDO&lt;/span&gt;::&lt;span class=&quot;ST1&quot;&gt;ATTR_ERRMODE&lt;/span&gt;, &lt;span class=&quot;ST0&quot;&gt;PDO&lt;/span&gt;::&lt;span class=&quot;ST1&quot;&gt;ERRMODE_EXCEPTION&lt;/span&gt;);
    } &lt;span class=&quot;keyword&quot;&gt;catch&lt;/span&gt; (&lt;span class=&quot;ST2&quot;&gt;PDOException&lt;/span&gt; &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$ex&lt;/span&gt;) {
        &lt;span class=&quot;keyword&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;string&quot;&gt;&#39;Connection failed: &#39;&lt;/span&gt; . &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$e&lt;/span&gt;x-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;getMessage&lt;/span&gt;();
    }
  
  &lt;b&gt;  &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;The example shown above is handling the exception&lt;/span&gt;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;if  the connection using pdo is failed then it will&lt;/span&gt;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt;echo connection faild adn the errormessage which is  generated by PDOException class&lt;/span&gt;
&lt;/b&gt;&lt;span class=&quot;ST0&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/6221979038521214741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/6221979038521214741' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/6221979038521214741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/6221979038521214741'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-pdo-exception-handling-error-mode.html' title='Php Pdo Exception Handling - Error mode in Php Pdo'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-5888143598012867559</id><published>2012-09-11T04:19:00.001-07:00</published><updated>2012-09-11T04:19:46.288-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Installation Php"/><title type='text'>Php installing  MAMP on Mac Os</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The Steps to install MAMP are as below.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Download software : &lt;a href=&quot;http://mamp.info/en/download.html&quot; onclick=&quot;javascript:_gaq.push([&#39;_trackEvent&#39;,&#39;outbound-article&#39;,&#39;http://mamp.info&#39;]);&quot;&gt;http://mamp.info/en/&lt;/a&gt;&lt;/b&gt;Click Download Now button. (MAMP is free, but the download also includes the commercial product, MAMP Pro, which makes administering MAMP easier.&lt;br /&gt;
MAMP Pro is not needed for this tutorial, and you don’t have to install it either.)&lt;br /&gt;
Unzip the file and then, License Agreement will appear; click Agree.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=8859447625947777020&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=8859447625947777020&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7msdiq2UM4zDhL1k_gZxW73RlOH8MKn_2a371gBZjE4XiJytefYgh8IQ4E5tP3bhWBQN_r9st_D1E6jaEGOME9xzEZuJUxfulz0-nBYMVF12xs0TC6Kqgt16i6M0roTjOVTcN2r1pIz4/s1600/mamp_files.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7msdiq2UM4zDhL1k_gZxW73RlOH8MKn_2a371gBZjE4XiJytefYgh8IQ4E5tP3bhWBQN_r9st_D1E6jaEGOME9xzEZuJUxfulz0-nBYMVF12xs0TC6Kqgt16i6M0roTjOVTcN2r1pIz4/s400/mamp_files.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre&gt;&lt;b&gt;Snap 1:&lt;/b&gt; Installing MAMP is just a process of downloading a 
 file, unzip it, and dragging the MAMP folder into your Applications folder.


&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Now, you need to start the Web server.&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;b&gt;TIP: &lt;/b&gt;Since you’ll frequently access the MAMP program to turn the Web
 server on and off, it’s a good idea to add it to the OS X Dock.&lt;/pre&gt;
&lt;br /&gt;
In &lt;b&gt;Applications-&amp;gt;MAMP,&lt;/b&gt; start the MAMP program, and then click the Start Servers button if a red light appears to the left of either Apache or MySQL&lt;b&gt; (see Snap2&lt;/b&gt;&lt;b&gt;)&lt;/b&gt;.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRU_ngD157Gp84lSVnRiAVOwRmpzWXwI8FYMesjoqME4gZERZ0qNJ-l7tQ8kNpCfVufcqmW7AuRRUtu0uMvzhB13u2ztSBIC9T6XC9WpTRzYlCPKOywztJp3iXu1CFOhU88dAjiktj4QM/s1600/mamp_ports.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5u7sJ-SbCeH8wvuGusH74JEhEhba8UgM9VOlJHPhDdLDHF2nX4I8VPUn1_Lc5x5Q3S2MByvcgP_Y2ZTKZLj91Ednt8SxtXY9DGXsABQycwZVhsUVEklNC2Ck7JzR7kDk3ELXxvGxPZM0/s1600/mamp_program.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;325&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5u7sJ-SbCeH8wvuGusH74JEhEhba8UgM9VOlJHPhDdLDHF2nX4I8VPUn1_Lc5x5Q3S2MByvcgP_Y2ZTKZLj91Ednt8SxtXY9DGXsABQycwZVhsUVEklNC2Ck7JzR7kDk3ELXxvGxPZM0/s400/mamp_program.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;b&gt;Snap 2:&lt;/b&gt; When the servers are running, a green button to the left of 
Apache Server and MySQL Server lights up. To stop the servers, click the Stop
 Servers button. A red light next to either server indicates that the 
server is turned off.&lt;/pre&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRU_ngD157Gp84lSVnRiAVOwRmpzWXwI8FYMesjoqME4gZERZ0qNJ-l7tQ8kNpCfVufcqmW7AuRRUtu0uMvzhB13u2ztSBIC9T6XC9WpTRzYlCPKOywztJp3iXu1CFOhU88dAjiktj4QM/s1600/mamp_ports.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;325&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRU_ngD157Gp84lSVnRiAVOwRmpzWXwI8FYMesjoqME4gZERZ0qNJ-l7tQ8kNpCfVufcqmW7AuRRUtu0uMvzhB13u2ztSBIC9T6XC9WpTRzYlCPKOywztJp3iXu1CFOhU88dAjiktj4QM/s400/mamp_ports.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre&gt;&lt;b&gt;Snap 3:&lt;/b&gt; After installing MAMP , set Apache and MySQL to
 their normal port settings of 80 and 3306. You can’t do this setting, 
however, if you don’t have administrator privileges for your computer. In that 
case, you have to stick to the 8888 and 8889 port settings that MAMP ships 
with. When you visit a Web page running on your local server, you have to add 
the port, like this: http://localhost:8888/my_cool_page.php.


&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_feiCwsC2sTeeQyrMtnYEHHUfYUz6v3mrjlASCXxbiWISPIWRl_pc5r-1DQTU2K0HYAjsOIOOP7U80tghIxwkLLQbjswjB8yUzLDZItvZM8lJdIP1c2bw_UNZ5ystaZLUXz_jh7TOXcY/s1600/mamp_page.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_feiCwsC2sTeeQyrMtnYEHHUfYUz6v3mrjlASCXxbiWISPIWRl_pc5r-1DQTU2K0HYAjsOIOOP7U80tghIxwkLLQbjswjB8yUzLDZItvZM8lJdIP1c2bw_UNZ5ystaZLUXz_jh7TOXcY/s640/mamp_page.png&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;pre&gt;&amp;nbsp;&lt;b&gt;Snap 4:&lt;/b&gt; The MAMP home page gives you access to a few useful tools, 
like phpMyAdmin, which you’ll use for working with MySQL databases. You 
can always go to the MAMP homepage by typing its URL: 
&lt;b&gt;http://localhost/MAMP&lt;/b&gt;; or, in the MAMP controller program, clicking the Open 
Start Page button (Snap 2).



&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/5888143598012867559/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/5888143598012867559' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/5888143598012867559'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/5888143598012867559'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-installing-mamp-on-mac-os.html' title='Php installing  MAMP on Mac Os'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7msdiq2UM4zDhL1k_gZxW73RlOH8MKn_2a371gBZjE4XiJytefYgh8IQ4E5tP3bhWBQN_r9st_D1E6jaEGOME9xzEZuJUxfulz0-nBYMVF12xs0TC6Kqgt16i6M0roTjOVTcN2r1pIz4/s72-c/mamp_files.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-6255122102050507991</id><published>2012-09-07T06:37:00.000-07:00</published><updated>2012-09-07T06:38:19.703-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php PDO"/><title type='text'>Php PDO Transactions - BeginTransaction,RollBack,Commit </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;highlight-caret-row&quot;&gt;In transaction management query&amp;nbsp; is not actually applied to database &lt;/span&gt;untill we does not commit the transaction.&lt;br /&gt;
And if any error occurs then we can rollback the transaction to 
the previous state.&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Understanding Basic Transaction Flow&amp;nbsp;&lt;/h2&gt;
&lt;pre&gt;&lt;b&gt;&lt;span class=&quot;ST0&quot; style=&quot;color: black;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;/b&gt;
&lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt; Begin transaction&lt;/span&gt;
&lt;b&gt;&lt;span class=&quot;keyword&quot;&gt;If&lt;/span&gt;&lt;/b&gt;(&lt;span class=&quot;ST0&quot;&gt;success&lt;/span&gt;)
{
   &lt;span class=&quot;keyword&quot;&gt;If&lt;/span&gt;(&lt;span class=&quot;ST0&quot;&gt;success&lt;/span&gt;)
   {      &lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt; Commit the transaction&lt;/span&gt;   }
   &lt;b&gt;&lt;span class=&quot;keyword&quot;&gt;else&lt;/span&gt;&lt;/b&gt;
   {      &lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt; Roll back the transaction&lt;/span&gt;   }
}
&lt;b&gt;&lt;span class=&quot;keyword&quot;&gt;else&lt;/span&gt;&lt;/b&gt;
{
   &lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt; Rollback the transaction&lt;/span&gt;
}
&lt;b&gt;&lt;span class=&quot;ST0&quot; style=&quot;color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/b&gt;
&lt;/pre&gt;
&lt;br /&gt;
Using &lt;b&gt;Php PDO &lt;/b&gt;we can manage transaction easily.&lt;br /&gt;
Here is some Explanation of How &lt;b&gt;Php PDO&lt;/b&gt;  transactions works.&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
PDO::beginTransaction– commit the transaction&lt;/h2&gt;
&lt;b&gt;PDO::beginTransaction()&lt;/b&gt; used to begin the transaction. 
This function will return true on success and false on error. 
By calling this function autocommit mode will gets turned off. 
&lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Begin a transaction &lt;/span&gt;
&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$obj&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;beginTransaction&lt;/span&gt;();
&lt;span class=&quot;ST0&quot;&gt;?&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
PDO::commit – commit the transaction&lt;/h2&gt;
&lt;b&gt;PDO::commit()&lt;/b&gt; is used to commit  any changed made to DB via &lt;b&gt;PDO &lt;/b&gt;object. 
This will return true on success and false on error.The return type is boolean.
Basically this will commit a transaction and autocommit the database connection  until the next  beginTransaction call.
&lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Begin a transaction&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$obj&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;beginTransaction&lt;/span&gt;();
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Change the database schema&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$obj&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;exec&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&quot;DROP TABLE books&quot;&lt;/span&gt;);
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Commit the changes &lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$obj&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;commit&lt;/span&gt;();
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Database connection is now back in autocommit mode &lt;/span&gt;
&lt;span class=&quot;ST0&quot;&gt;?&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
PDO::rollBack – Roll back a Transaction&lt;/h2&gt;
&lt;b&gt;PDO::rollback() &lt;/b&gt;will rollback all changes made to database after calling beginTransaction statement
and return the connection to autocommit mode.&lt;br /&gt;
The return type is boolean.This also return true on success and false on error.&lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Begin a transaction, turning off autocommit &lt;/span&gt;
&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$obj&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;beginTransaction&lt;/span&gt;();
&lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Change the database schema and some data &lt;/span&gt;
&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$obj&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;exec&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&quot;UPDATE books SET name = &#39;PhpBooks&#39;&quot;&lt;/span&gt;);
&lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Recognize mistake and roll back changes &lt;/span&gt;
&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$obj&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;rollBack&lt;/span&gt;();
&lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Database connection is now back in autocommit mode &lt;/span&gt;
?&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/6255122102050507991/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/6255122102050507991' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/6255122102050507991'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/6255122102050507991'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-pdo-transactions.html' title='Php PDO Transactions - BeginTransaction,RollBack,Commit '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-8242861113119491697</id><published>2012-09-07T05:33:00.000-07:00</published><updated>2012-09-09T22:12:41.492-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php Lessons"/><title type='text'>Php PDO: Prepare Statement with Insert and Update </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Insert data in books table using &lt;b&gt;Php PDO&lt;/b&gt;.&lt;br /&gt;
The example below will insert title &quot;&lt;b&gt;Php Pamplates&lt;/b&gt;&quot; and author &quot;&lt;b&gt;Kishor&lt;/b&gt;&quot; in books table.&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Example: Insert query with PDO prepare statement&lt;/h2&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
       &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; configuration variables&lt;/span&gt;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbhost&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;localhost&quot;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbname&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;mydatabase&quot;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbuser&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;root&quot;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;dbpass&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;&quot;&lt;/span&gt;;        
        &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; database connection&lt;/span&gt;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$connection&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;PDO&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;mysql:host=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbhost&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;;dbname=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbname&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbuser&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;dbpass&lt;/span&gt;);
         
        &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; new data&lt;/span&gt;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$title&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;Php Pamplates&#39;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$author&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;Kishor&#39;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sql&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;INSERT INTO books (title,author) VALUES (:title,:author)&quot;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt; = &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$connection&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;prepare&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sql&lt;/span&gt;);
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;execute&lt;/span&gt;(&lt;span class=&quot;keyword&quot;&gt;array&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&#39;:author&#39;&lt;/span&gt;=&amp;gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$author&lt;/span&gt;,&lt;span class=&quot;string&quot;&gt;&#39;:title&#39;&lt;/span&gt;=&amp;gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$title&lt;/span&gt;));
&lt;span class=&quot;ST0&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
Now, Update data in books table using &lt;b&gt;Php PDO&lt;/b&gt;.&lt;br /&gt;
The example below will update title to &quot;&lt;b&gt;Php Books&lt;/b&gt;&quot; and author to &quot;&lt;b&gt;Hiren&lt;/b&gt;&quot; in books table where id&lt;br /&gt;
is 1.&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Example: Update query with PDO prepare statement&lt;/h2&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
        &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; configuration variables&lt;/span&gt;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbhost&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;localhost&quot;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbname&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;mydatabase&quot;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbuser&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;root&quot;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;dbpass&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;&quot;&lt;/span&gt;;        
        &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; database connection&lt;/span&gt;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$connection&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;PDO&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;mysql:host=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbhost&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;;dbname=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbname&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbuser&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;dbpass&lt;/span&gt;);
        &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; data to be updated in id 1&lt;/span&gt;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$title&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;Php Books&#39;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$author&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;Hiren&#39;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$id&lt;/span&gt; = &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;;
        &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; query&lt;/span&gt;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sql&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;UPDATE books SET title=?, author=? WHERE id=?&quot;&lt;/span&gt;;
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt; = &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$connection&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;prepare&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sql&lt;/span&gt;);
        &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;execute&lt;/span&gt;(&lt;span class=&quot;keyword&quot;&gt;array&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$title&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$author&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$id&lt;/span&gt;));
         
?&amp;gt;       
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/8242861113119491697/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/8242861113119491697' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/8242861113119491697'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/8242861113119491697'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-pdo-prepare-statement-with-insert.html' title='Php PDO: Prepare Statement with Insert and Update '/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-4426869675494889873</id><published>2012-09-07T05:05:00.000-07:00</published><updated>2012-09-07T05:37:50.434-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php PDO"/><title type='text'>Php PDO: Prepared Statement</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Prepare statement is the method of Php PDO.&lt;br /&gt;
The &lt;b&gt;prepare()&lt;/b&gt; statement is used to build the query while we are using &lt;b&gt;Php PDO&lt;/b&gt;. &lt;br /&gt;
&lt;br /&gt;
Once the prepare statement is declared with query then The values in&amp;nbsp; that query is passed&amp;nbsp; as array format using execute method of &lt;b&gt;PDO&lt;/b&gt;. The example below shows the use of prepare statement in Php PDO.&lt;br /&gt;
&lt;h2 style=&quot;color: black; text-align: left;&quot;&gt;
&lt;b&gt;Example : 
&lt;/b&gt;&lt;/h2&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt; database connection&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$connection&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST1&quot;&gt;PDO&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;mysql:host=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbhost&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;;dbname=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbname&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbuser&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbpass&lt;/span&gt;);

    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$title&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;echonomic%&#39;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST2&quot;&gt;author&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&#39;Hiren%&#39;&lt;/span&gt;;
    &lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt; query&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sql&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;SELECT * FROM books WHERE title like ? AND author like ? &quot;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt; = &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$connection&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;prepare&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sql&lt;/span&gt;);


    //Now passsing the variables to query and execute it
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;execute&lt;/span&gt;(&lt;span class=&quot;keyword&quot;&gt;array&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$title&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST2&quot;&gt;author&lt;/span&gt;)); &lt;span class=&quot;PHP_VARIABLE&quot;&gt;   &lt;/span&gt;
&lt;span class=&quot;PHP_VARIABLE&quot;&gt;    query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;setFetchMode&lt;/span&gt;(&lt;span class=&quot;ST0&quot;&gt;PDO&lt;/span&gt;::&lt;span class=&quot;ST1&quot;&gt;FETCH_BOTH&lt;/span&gt;);

&lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt;    //&lt;/span&gt;&lt;span class=&quot;comment&quot; style=&quot;color: black;&quot;&gt; fetch&lt;/span&gt;
&lt;span class=&quot;keyword&quot;&gt;    while&lt;/span&gt; (&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST2&quot;&gt;result&lt;/span&gt; = &lt;span class=&quot;PHP_VARIABLE&quot;&gt;query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST0&quot;&gt;fetch&lt;/span&gt;()) {
       &lt;span class=&quot;ST0&quot;&gt;print_r&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST2&quot;&gt;r&lt;/span&gt;esult);
     }
?&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
In the above example, query depends on a variabel (?).
&lt;br /&gt;
This script will output the books which has title starts with &lt;b&gt;echonomics &lt;/b&gt;and author starts with &lt;b&gt;Hiren. &lt;/b&gt;&lt;br /&gt;
&lt;br/&gt;&lt;b&gt;&lt;a href=&quot;http://hirengprajapati.blogspot.in/2012/09/php-pdo-prepare-statement-with-insert.html&quot; target=&quot;_blank&quot;&gt;Click to view More Examples using PDO prepare() statement&lt;/a&gt;&lt;/b&gt;&lt;b&gt;.&lt;/b&gt;&lt;br /&gt;
&lt;br/&gt;
&lt;b&gt;&lt;span style=&quot;color: red;&quot;&gt;Note&lt;/span&gt; : Php Extension for mysql and SQLite does not support this kind of functionality.
&lt;br/&gt;&lt;br/&gt;
&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/4426869675494889873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/4426869675494889873' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/4426869675494889873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/4426869675494889873'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-pdo-prepared-statement.html' title='Php PDO: Prepared Statement'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-1305355900774677962</id><published>2012-09-07T03:16:00.000-07:00</published><updated>2012-09-07T04:15:25.088-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php PDO"/><title type='text'>Php PDO Fetch methods - FETCH_ASSOC,FETCH_NUM,FETCH_BOTH,FETCH_OBJ</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;Php PDO&lt;/b&gt; has fetch methods which are explain as below
We generally use mysql database methods for php to retrieve data from database.Like
&lt;i&gt;&lt;b&gt;mysql_fetch_assoc&lt;/b&gt; ,&lt;b&gt;mysql_fetch_row&lt;/b&gt; ,&lt;b&gt;mysql_fetch_array&lt;/b&gt; ,&lt;b&gt;mysql_fetch_obj&lt;/b&gt;&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;In &lt;b&gt;Php PDO&lt;/b&gt;&amp;nbsp; 
we have to use different methods to fetch data from database. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Lets consider the connection and we are fetching books from books table &lt;/b&gt;&lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; database connection&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$conn&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST1&quot;&gt;PDO&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;mysql:host=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbhost&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;;dbname=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbname&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbuser&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbpass&lt;/span&gt;);
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sql&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;SELECT title FROM books ORDER BY title&quot;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt; = &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$conn&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;query&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$sql&lt;/span&gt;);

 &lt;span class=&quot;ST1&quot;&gt;?&amp;gt;&lt;/span&gt;&amp;nbsp;&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
PDO fetch method &lt;b&gt;&lt;span class=&quot;ST2&quot;&gt;FETCH_ASSOC&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;b style=&quot;color: black;&quot;&gt;Example :&lt;/b&gt;&lt;b&gt;&lt;span class=&quot;ST2&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;ST1&quot;&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Fetch using associative array&lt;/span&gt;.&lt;b&gt;&lt;span class=&quot;comment&quot;&gt;This method is similar to mysql_fetch_assoc&lt;/span&gt;&lt;/b&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;setFetchMode&lt;/span&gt;(&lt;span class=&quot;ST1&quot;&gt;PDO&lt;/span&gt;::&lt;span class=&quot;ST2&quot;&gt;FETCH_ASSOC&lt;/span&gt;);
    &lt;span class=&quot;keyword&quot;&gt;while&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$result&lt;/span&gt; = &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;fetch&lt;/span&gt;()){
    &lt;span class=&quot;ST3&quot;&gt;print_r&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$result&lt;/span&gt;);
}
&lt;span class=&quot;ST1&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;b&gt;Result:&lt;/b&gt;&lt;/div&gt;
Array ( [title] =&amp;gt; Book 1) &lt;br /&gt;
Array ( [title] =&amp;gt; Book 2)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
PDO fetch method &lt;b&gt;&lt;span class=&quot;ST2&quot;&gt;FETCH_NUM&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;b style=&quot;color: black;&quot;&gt;Example :&lt;/b&gt;&lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;ST2&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Fetch as numeric array&lt;/span&gt;.
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;setFetchMode&lt;/span&gt;(&lt;span class=&quot;ST1&quot;&gt;PDO&lt;/span&gt;::&lt;span class=&quot;ST2&quot;&gt;FETCH_NUM&lt;/span&gt;);
    &lt;span class=&quot;keyword&quot;&gt;while&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$result&lt;/span&gt; = &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;fetch&lt;/span&gt;()){
    &lt;span class=&quot;ST3&quot;&gt;print_r&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$result&lt;/span&gt;);
}
&lt;span class=&quot;ST1&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;b&gt;Result:&lt;/b&gt;&lt;/div&gt;
Array ( [0] =&amp;gt; Book 1 ) &lt;br /&gt;
Array ( [0] =&amp;gt; Book 2 )&lt;br /&gt;
&lt;br b=&quot;b&quot; /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
PDO fetch method &lt;b&gt;&lt;span class=&quot;ST2&quot;&gt;FETCH_BOTH&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;b&gt;Example :&lt;/b&gt;&lt;b&gt;&lt;span class=&quot;ST2&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;/div&gt;
&lt;pre&gt;&lt;span class=&quot;ST1&quot;&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Fetch as associative array and numeric array both.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;comment&quot;&gt;This method&amp;nbsp;&lt;/span&gt;&lt;/b&gt;
&lt;b&gt;&lt;span class=&quot;comment&quot;&gt;       is similar to mysql_fetch_array &lt;/span&gt;&lt;/b&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;setFetchMode&lt;/span&gt;(&lt;span class=&quot;ST1&quot;&gt;PDO&lt;/span&gt;::&lt;span class=&quot;ST2&quot;&gt;FETCH_BOTH&lt;/span&gt;);
    &lt;span class=&quot;keyword&quot;&gt;while&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$result&lt;/span&gt; = &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;fetch&lt;/span&gt;()){
    &lt;span class=&quot;ST3&quot;&gt;print_r&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$result&lt;/span&gt;);
}
&lt;span class=&quot;ST1&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;b&gt;Result:&lt;/b&gt;&lt;/div&gt;
Array ( [title] =&amp;gt; Book 1 [0] =&amp;gt; Book 1 ) &lt;br /&gt;
Array ( [title] =&amp;gt; Book 2 [0] =&amp;gt; Book 2 )&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
PDO fetch method &lt;b&gt;&lt;span class=&quot;ST2&quot;&gt;FETCH_OBJ&lt;/span&gt;&lt;/b&gt;&lt;/h2&gt;
&lt;b style=&quot;color: black;&quot;&gt;Example :&lt;/b&gt;&lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;ST1&quot;&gt;&amp;lt;?php&lt;/span&gt;
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; Fetch as object.&lt;b&gt;This method is similar to mysql_fetch_obj&lt;/b&gt; &lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;setFetchMode&lt;/span&gt;(&lt;span class=&quot;ST1&quot;&gt;PDO&lt;/span&gt;::&lt;span class=&quot;ST2&quot;&gt;FETCH_OBJ&lt;/span&gt;);
    &lt;span class=&quot;keyword&quot;&gt;while&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$result&lt;/span&gt; = &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$query&lt;/span&gt;-&amp;gt;&lt;span class=&quot;ST1&quot;&gt;fetch&lt;/span&gt;()){
    &lt;span class=&quot;ST3&quot;&gt;print_r&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$result&lt;/span&gt;);
}
&lt;span class=&quot;ST1&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;b&gt;Result :&lt;/b&gt;&lt;/div&gt;
stdClass Object &lt;br /&gt;
( &lt;br /&gt;
[title] =&amp;gt;Book 1 &lt;br /&gt;
)&lt;br /&gt;
stdClass Object &lt;br /&gt;
( &lt;br /&gt;
[title] =&amp;gt;Book 2 &lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/1305355900774677962/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/1305355900774677962' title='13 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/1305355900774677962'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/1305355900774677962'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-pdo-fetch-methods.html' title='Php PDO Fetch methods - FETCH_ASSOC,FETCH_NUM,FETCH_BOTH,FETCH_OBJ'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>13</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-7983619994486630166</id><published>2012-09-05T23:40:00.000-07:00</published><updated>2012-09-05T23:40:20.433-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php PDO"/><title type='text'>Connect to Database using Php PDO</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Database Connection using Php PDO&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;highlight-caret-row&quot;&gt;Connect to Database with &lt;b&gt;PDO&lt;/b&gt;&lt;/span&gt;&lt;b&gt;
&lt;/b&gt;Line of code for connect to database.&lt;br /&gt;
When we want to change database, we just rewrite one line code.&lt;br /&gt;
Not all code. Below is Php script to connect to several database:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;   &lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
                &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; for MySQL&lt;/span&gt;
                &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$conn&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;PDO&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;mysql:host=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$host&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;;dbname=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$db&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;, &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$user&lt;/span&gt;, &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$pass&lt;/span&gt;);    
                &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; for SQLite&lt;/span&gt;
                &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$conn&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;PDO&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;sqlite:&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$db&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;);   
                &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; for postgreSQL&lt;/span&gt;
                &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$conn&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;PDO&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;pgsql:host=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$host&lt;/span&gt;&lt;span class=&quot;string&quot;&gt; dbname=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$db&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;, &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$user&lt;/span&gt;, &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$pass&lt;/span&gt;);
        &lt;span class=&quot;ST0&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;br /&gt;
Looking the script below:&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;      &lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
                &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; configuration variables&lt;/span&gt;
                &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbtype&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;sqlite&quot;&lt;/span&gt;;
                &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbhost&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;localhost&quot;&lt;/span&gt;;
                &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbname&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;test&quot;&lt;/span&gt;;
                &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbuser&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;root&quot;&lt;/span&gt;;
                &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbpass&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;admin&quot;&lt;/span&gt;;
                &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbpath&lt;/span&gt;     = &lt;span class=&quot;string&quot;&gt;&quot;c:/test.db&quot;&lt;/span&gt;;      
                &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; switching for database selection&lt;/span&gt;
                &lt;span class=&quot;keyword&quot;&gt;switch&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbtype&lt;/span&gt;){
                  &lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;string&quot;&gt;&quot;mysql&quot;&lt;/span&gt;:
                    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbconn&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;mysql:host=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbhost&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;;dbname=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbname&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;;
                    &lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;;

                  &lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;string&quot;&gt;&quot;sqlite&quot;&lt;/span&gt;:
                    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbconn&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;sqlite:&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbpath&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;;
                    &lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;;

                  &lt;span class=&quot;keyword&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;string&quot;&gt;&quot;postgresql&quot;&lt;/span&gt;:
                    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbconn&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;pgsql:host=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbhost&lt;/span&gt;&lt;span class=&quot;string&quot;&gt; dbname=&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbname&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;;
                    &lt;span class=&quot;keyword&quot;&gt;break&lt;/span&gt;;
                }        
                &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; database connection using PDO&lt;/span&gt;
                &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$connection&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;ST0&quot;&gt;PDO&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$dbconn&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$username&lt;/span&gt;,&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST1&quot;&gt;password&lt;/span&gt;);
     
        &lt;span class=&quot;ST0&quot;&gt;?&amp;gt;&lt;/span&gt;
   &lt;/pre&gt;
This is sample script to create database connection using &lt;b&gt;PDO&lt;/b&gt;.&lt;br /&gt;
It is more portable, because when we change database, we just change at configuration part .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/7983619994486630166/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/7983619994486630166' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/7983619994486630166'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/7983619994486630166'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/connect-to-database-using-php-pdo.html' title='Connect to Database using Php PDO'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-2686244017270130561</id><published>2012-09-05T05:58:00.001-07:00</published><updated>2012-09-05T05:58:33.256-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php PDO"/><title type='text'>What is Php PDO ?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;b&gt;PHP Data Object &lt;/b&gt;is a Database Connection Abstraction Library for&lt;b&gt; PHP 5.&lt;/b&gt;&lt;/div&gt;
PDO is extension written in a compiled language (C/C++).&lt;br /&gt;
It is a Lightweight Database abstract library.&lt;br /&gt;
&lt;h3 style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Why to use PDO?&lt;/span&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;PDO &lt;/b&gt;Supports number of database systems supported by PHP&lt;/li&gt;
&lt;li&gt;You need not to code for many database in php. Just write one and run anywhere&lt;/li&gt;
&lt;li&gt;&lt;b&gt;PDO &lt;/b&gt;is written in compiled language so &lt;b&gt;its speed is more than PHP libraries &lt;/b&gt;(&lt;b&gt;ADOdb, PEAR DB&lt;/b&gt;) which are written in an interpreted language.&lt;/li&gt;
&lt;li&gt;It is very easy to install.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;



&lt;/ul&gt;
&lt;h3 style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;When to use PDO?&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
when we&amp;nbsp; develope Application from scratch, and also for getting speed we should use &lt;b&gt;PDO. &lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: large;&quot;&gt;How to Activate Php PDO ?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
If php PDO extension is not enable in your php configuration then&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Go to &lt;b&gt;php.ini&lt;/b&gt; and&amp;nbsp; remove comment from directives as below.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre&gt;&lt;span style=&quot;color: blue;&quot;&gt;extension&lt;/span&gt; = php_pdo.dll
&lt;span style=&quot;color: blue;&quot;&gt;extension&lt;/span&gt; = php_pdo_mysql.dll&amp;nbsp;&lt;/pre&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi71EqI9k14Jren7oHv9OzA_KvfA0KPt5cWiPdzOcg2qgUOO2OW6nksdQi4qFxeYME6rxlNuEOL3kPDHHJEFnBEHczMO2HUks481AvMtDJb8YOVwm7ZEF8ntnqm5tOrgQq7HPHHtNrC-JQ/s1600/pdo_01_02.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Now Restart the &lt;b&gt;Apache&lt;/b&gt;. And Done.
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/2686244017270130561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/2686244017270130561' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/2686244017270130561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/2686244017270130561'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/what-is-php-pdo.html' title='What is Php PDO ?'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-8431618030340220299</id><published>2012-09-05T02:20:00.002-07:00</published><updated>2012-09-05T04:16:55.729-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php Lessons"/><title type='text'>Sending email with multiple attachments using PHP Script</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Using &lt;b&gt;mail()&lt;/b&gt; function we can send simple mail see &lt;a href=&quot;http://hirengprajapati.blogspot.in/2012/09/php-simple-e-mail-script.html&quot; target=&quot;_blank&quot;&gt;simple mail()&lt;/a&gt; script.&lt;br /&gt;
We can also send multiple attachement using php code and using php mail() function&lt;br /&gt;
For this we have to use MIME extenstion&lt;br /&gt;
&lt;br /&gt;
The example below shows how to send multiple attachements with mail. &lt;br /&gt;
We have to create one array of files which we want to send in attachement by brosing from interface.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b style=&quot;color: black;&quot;&gt;Example:&lt;/b&gt;&lt;br /&gt;
&lt;pre&gt;&lt;span class=&quot;ST0&quot;&gt;&amp;lt;?php&lt;/span&gt;
 
    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; array with filenames to be sent as attachment&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$files&lt;/span&gt; = &lt;span class=&quot;keyword&quot;&gt;array&lt;/span&gt;(&lt;span class=&quot;string&quot;&gt;&quot;file1.jpg&quot;&lt;/span&gt;,&lt;span class=&quot;string&quot;&gt;&quot;file2.pdf&quot;&lt;/span&gt;,&lt;span class=&quot;string&quot;&gt;&quot;file3.txt&quot;&lt;/span&gt;);

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; email fields: to, from, subject, and so on&lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$to&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;yourmail@mail.com&quot;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$from&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;mymail@mail.com&quot;&lt;/span&gt;; 
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$subject&lt;/span&gt; =&lt;span class=&quot;string&quot;&gt;&quot;My subject&quot;&lt;/span&gt;; 
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$message&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;My message&quot;&lt;/span&gt;;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$headers&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;From: &lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$from&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;;

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; boundary &lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$semi_rand&lt;/span&gt; = &lt;span class=&quot;ST1&quot;&gt;md5&lt;/span&gt;(&lt;span class=&quot;ST1&quot;&gt;time&lt;/span&gt;()); 
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$mime_boundary&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;==Multipart_Boundary_x&lt;/span&gt;{&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$semi_rand&lt;/span&gt;}&lt;span class=&quot;string&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;; 

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; headers for attachment &lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$headers&lt;/span&gt; .= &lt;span class=&quot;string&quot;&gt;&quot;\nMIME-Version: 1.0\n&quot;&lt;/span&gt; . &lt;span class=&quot;string&quot;&gt;&quot;Content-Type: multipart/mixed;\n&quot;&lt;/span&gt; .   &quot;
&lt;span class=&quot;string&quot;&gt;                 boundary=\&quot;&lt;/span&gt;{&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$mime_boundary&lt;/span&gt;}&lt;span class=&quot;string&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;; 

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; multipart boundary &lt;/span&gt;
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$message&lt;/span&gt; = &lt;span class=&quot;string&quot;&gt;&quot;This is a multi-part message in MIME format.\n\n&quot;&lt;/span&gt; . &lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;--&lt;/span&gt;{&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$mime_boundary&lt;/span&gt;}&lt;span class=&quot;string&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;string&quot;&gt;             &amp;nbsp;&lt;/span&gt; . &lt;span class=&quot;string&quot;&gt;&quot;Content-Type: text/plain; charset=\&quot;iso-8859-1\&quot;\n&quot;&lt;/span&gt; . 
&lt;span class=&quot;string&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;                &quot;Content-Transfer-Encoding: 7bit\n\n&quot;&lt;/span&gt; . &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$message&lt;/span&gt; . &lt;span class=&quot;string&quot;&gt;&quot;\n\n&quot;&lt;/span&gt;; 
    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$message&lt;/span&gt; .= &lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;--&lt;/span&gt;{&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$mime_boundary&lt;/span&gt;}&lt;span class=&quot;string&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;;

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; preparing attachments&lt;/span&gt;
    &lt;span class=&quot;keyword&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$x&lt;/span&gt;=&lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$x&lt;/span&gt;&amp;lt;&lt;span class=&quot;ST1&quot;&gt;count&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$files&lt;/span&gt;);&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$x&lt;/span&gt;++){
            &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST2&quot;&gt;file&lt;/span&gt; = &lt;span class=&quot;ST1&quot;&gt;fopen&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$files&lt;/span&gt;[&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$x&lt;/span&gt;],&lt;span class=&quot;string&quot;&gt;&quot;rb&quot;&lt;/span&gt;);
            &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$data&lt;/span&gt; = &lt;span class=&quot;ST1&quot;&gt;fread&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST2&quot;&gt;file&lt;/span&gt;,&lt;span class=&quot;ST1&quot;&gt;filesize&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$files&lt;/span&gt;[&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$x&lt;/span&gt;]));
            &lt;span class=&quot;ST1&quot;&gt;fclose&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;ST2&quot;&gt;file&lt;/span&gt;);
            &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$data&lt;/span&gt; = &lt;span class=&quot;ST1&quot;&gt;chunk_split&lt;/span&gt;(&lt;span class=&quot;ST1&quot;&gt;base64_encode&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$data&lt;/span&gt;));
            &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$message&lt;/span&gt; .= &lt;span class=&quot;string&quot;&gt;&quot;Content-Type: {\&quot;application/octet-stream\&quot;};\n&quot;&lt;/span&gt; . &lt;span class=&quot;string&quot;&gt;&amp;nbsp;&lt;/span&gt;

&lt;span class=&quot;string&quot;&gt;                        &quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt; name=\&quot;&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$files&lt;/span&gt;[&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$x&lt;/span&gt;]&lt;span class=&quot;string&quot;&gt;\&quot;\n&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt; . 
            &lt;span class=&quot;string&quot;&gt;&quot;Content-Disposition: attachment;\n&quot;&lt;/span&gt; . &lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt; filename=\&quot;&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$files&lt;/span&gt;[&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$x&lt;/span&gt;]&lt;span class=&quot;string&quot;&gt;\&quot;\n&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt; . 
            &lt;span class=&quot;string&quot;&gt;&quot;Content-Transfer-Encoding: base64\n\n&quot;&lt;/span&gt; . &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$data&lt;/span&gt; . &lt;span class=&quot;string&quot;&gt;&quot;\n\n&quot;&lt;/span&gt;;
            &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$message&lt;/span&gt; .= &lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;--&lt;/span&gt;{&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$mime_boundary&lt;/span&gt;}&lt;span class=&quot;string&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;;
    }

    &lt;span class=&quot;comment&quot;&gt;//&lt;/span&gt;&lt;span class=&quot;comment&quot;&gt; send&lt;/span&gt;

    &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$success &lt;/span&gt;= @&lt;span class=&quot;ST1&quot;&gt;mail&lt;/span&gt;(&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$to&lt;/span&gt;, &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$subject&lt;/span&gt;, &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$message&lt;/span&gt;, &lt;span class=&quot;PHP_VARIABLE&quot;&gt;$headers&lt;/span&gt;); 
    &lt;span class=&quot;keyword&quot;&gt;if&lt;/span&gt; (&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;success&lt;/span&gt;) { 
            &lt;span class=&quot;keyword&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&amp;lt;p&amp;gt;mail sent to &lt;/span&gt;&lt;span class=&quot;PHP_VARIABLE&quot;&gt;$to&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;!&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;&quot;&lt;/span&gt;; 
    } &lt;span class=&quot;keyword&quot;&gt;else&lt;/span&gt; { 
            &lt;span class=&quot;keyword&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;string&quot;&gt;&quot;&amp;lt;p&amp;gt;mail could not be sent!&amp;lt;/p&amp;gt;&quot;&lt;/span&gt;; 
    } 
 
?&amp;gt;


&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/8431618030340220299/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/8431618030340220299' title='44 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/8431618030340220299'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/8431618030340220299'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/sending-email-with-multiple-attachments.html' title='Sending email with multiple attachments using PHP Script'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>44</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-834515135216498879</id><published>2012-09-04T05:01:00.001-07:00</published><updated>2012-09-05T02:48:22.637-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Learn Php Basics"/><title type='text'>Php Simple E-mail Script</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
The PHP&lt;b&gt; mail() &lt;/b&gt;function is used to send emails from a script.&lt;br /&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;b&gt;Syntax:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;color: black;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;code notranslate&quot;&gt;
&lt;div&gt;
&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: blue;&quot;&gt;mail&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: lime;&quot;&gt;(&lt;/span&gt;&lt;i style=&quot;color: black;&quot;&gt;to, subject, message ,headers, parameters&lt;/i&gt;&lt;span style=&quot;color: lime;&quot;&gt;)&lt;/span&gt;&lt;/b&gt;

&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;2&quot; cellspacing=&quot;1&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; style=&quot;background-color: #999999; color: black;&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Params&lt;/th&gt;
 &lt;th align=&quot;left&quot; style=&quot;background-color: #999999; color: black;&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Required&lt;/th&gt;
    &lt;th align=&quot;left&quot; style=&quot;background-color: #999999; color: black;&quot; valign=&quot;top&quot; width=&quot;80%&quot;&gt;Explaination of parameters&lt;/th&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td style=&quot;color: black;&quot; valign=&quot;top&quot;&gt;to&lt;/td&gt;
 &lt;th align=&quot;left&quot; valign=&quot;top&quot;&gt;Yes&lt;/th&gt;
    &lt;td valign=&quot;top&quot;&gt;&amp;nbsp;Reciever&#39;s email address&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td style=&quot;background-color: #eeeeee; color: black;&quot; valign=&quot;top&quot;&gt;subject&lt;/td&gt; &lt;th align=&quot;left&quot; top=&quot;top&quot;&gt;Yes&lt;/th&gt;
    &lt;td style=&quot;background-color: #eeeeee;&quot; valign=&quot;top&quot;&gt;Specifies 
 the subject of the email.&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td style=&quot;color: black;&quot; valign=&quot;top&quot;&gt;message&lt;/td&gt; &lt;th align=&quot;left&quot; valign=&quot;top&quot;&gt;Yes&lt;/th&gt;
    &lt;td valign=&quot;top&quot;&gt;&amp;nbsp;Message to be sent. Each line should 
 be separated with a (\n). Lines should not longer than 70 characters&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td style=&quot;background-color: #eeeeee; color: black;&quot; valign=&quot;top&quot;&gt;headers&lt;/td&gt; &lt;th align=&quot;left&quot; style=&quot;background-color: #eeeeee; color: black;&quot; valign=&quot;top&quot;&gt;No&lt;/th&gt;
    &lt;td style=&quot;background-color: #eeeeee;&quot; valign=&quot;top&quot;&gt;Additional headers, like From, Cc, and 
 Bcc. The additional headers should be separated with&amp;nbsp; (\r\n)&lt;/td&gt;
  &lt;/tr&gt;
&lt;tr&gt;
    &lt;td style=&quot;color: black;&quot; valign=&quot;top&quot;&gt;parameters&lt;/td&gt; &lt;th align=&quot;left&quot; style=&quot;color: black;&quot; valign=&quot;top&quot;&gt;No&lt;/th&gt;
    &lt;td valign=&quot;top&quot;&gt;&amp;nbsp;Specifies an additional parameter to the sendmail program&lt;/td&gt;
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;b style=&quot;color: black;&quot;&gt;Note:&lt;/b&gt; PHP requires an installed&amp;nbsp; email system ro work email system. It is defined in the configuration 
settings in the &lt;b&gt;php.ini &lt;/b&gt;file. &lt;a href=&quot;http://hirengprajapati.blogspot.in/2012/09/e-mail-confuguration-in-php.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Click to View The configuration of mail()&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
&lt;h2&gt;
Example :&lt;/h2&gt;
The simplest example to send an email with PHP.&lt;br /&gt;
First declare the variables &lt;b&gt;$to, $subject, $message, 
$from, $headers &lt;/b&gt;then we use the variables in the &lt;b&gt;mail()&lt;/b&gt; function to send an e-mail:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b style=&quot;color: black;&quot;&gt;&amp;lt;?php&lt;/b&gt;

&lt;b&gt;$to = &quot;&lt;span style=&quot;color: blue;&quot;&gt;someone@example.com&lt;/span&gt;&quot;;&lt;/b&gt;

&lt;b&gt;$subject = &quot;&lt;span style=&quot;color: blue;&quot;&gt;Test mail&lt;/span&gt;&quot;;&lt;/b&gt;

&lt;b&gt;$message = &quot;&lt;span style=&quot;color: blue;&quot;&gt;Hello! This is a simple email message.&lt;/span&gt;&quot;;&lt;/b&gt;

&lt;b&gt;$from = &quot;&lt;span style=&quot;color: blue;&quot;&gt;someonelse@example.com&lt;/span&gt;&quot;;&lt;/b&gt;

&lt;b&gt;$headers = &quot;&lt;span style=&quot;color: blue;&quot;&gt;From:&lt;/span&gt;&quot; . $from;&lt;/b&gt;

&lt;b&gt;&lt;i&gt;&lt;span style=&quot;color: blue;&quot;&gt;mail&lt;/span&gt;&lt;/i&gt;&lt;span style=&quot;color: lime;&quot;&gt;(&lt;/span&gt;&lt;i style=&quot;color: black;&quot;&gt;$to&lt;/i&gt;&lt;span style=&quot;color: black;&quot;&gt;,&lt;/span&gt;&lt;i style=&quot;color: black;&quot;&gt;$subject,$message,$headers&lt;/i&gt;&lt;span style=&quot;color: lime;&quot;&gt;)&lt;/span&gt;;&lt;/b&gt;

&lt;b&gt;&lt;span style=&quot;color: #bf9000;&quot;&gt;echo &lt;/span&gt;&quot;&lt;span style=&quot;color: blue;&quot;&gt;Mail Sent.&lt;/span&gt;&quot;;&lt;/b&gt;

&lt;b&gt;?&amp;gt;

&lt;/b&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;http://hirengprajapati.blogspot.in/2012/09/sending-email-with-multiple-attachments.html&quot; target=&quot;_blank&quot;&gt;Click &lt;/a&gt;to view Script for Sending email with multiple attachement&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/834515135216498879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/834515135216498879' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/834515135216498879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/834515135216498879'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-simple-e-mail-script.html' title='Php Simple E-mail Script'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-2184221443075652912</id><published>2012-09-04T05:00:00.001-07:00</published><updated>2012-09-04T05:11:11.709-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Configuration Php"/><title type='text'>E-mail confuguration in Php</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Mail Configuration in Php&lt;/span&gt;&lt;/h2&gt;
The&lt;b&gt; mail()&lt;/b&gt; function allows you to send mails from a script directly&lt;br /&gt;
&lt;br /&gt;
PHP requires an installed and working 
email system for the mail function to work well. It works by 
the configuration settings in the &lt;b&gt;php.ini&lt;/b&gt; file.&lt;br /&gt;
&lt;h2&gt;
&lt;/h2&gt;
The &lt;b&gt;mail()&lt;/b&gt; functions is part of the PHP core. There is no installation 
needed to use these functions.&lt;br /&gt;
&lt;h2 style=&quot;color: black;&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Configuration&lt;/span&gt;&lt;/h2&gt;
we can set&lt;b&gt; mail()&lt;/b&gt; function configurations in &lt;b&gt;php.ini&lt;/b&gt; file with the directives as below.&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;2&quot; cellspacing=&quot;1&quot;&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;th align=&quot;left&quot; style=&quot;background-color: #cccccc;&quot; valign=&quot;top&quot; width=&quot;20%&quot;&gt;Name&lt;/th&gt;
    &lt;th align=&quot;left&quot; style=&quot;background-color: #cccccc;&quot; valign=&quot;top&quot; width=&quot;15%&quot;&gt;Default&lt;/th&gt;
    &lt;th align=&quot;left&quot; style=&quot;background-color: #cccccc;&quot; valign=&quot;top&quot; width=&quot;42%&quot;&gt;Description&lt;/th&gt;
   
  &lt;/tr&gt;
&lt;tr style=&quot;background-color: white;&quot;&gt;
    &lt;td style=&quot;color: black;&quot; valign=&quot;top&quot;&gt;SMTP&lt;/td&gt;
    &lt;td style=&quot;color: black;&quot; valign=&quot;top&quot;&gt;&quot;localhost&quot;&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;(&lt;b&gt;Windows&lt;/b&gt;) The DNS name or IP address of the SMTP 
 server&lt;/td&gt;

  &lt;/tr&gt;
&lt;tr style=&quot;background-color: white;&quot;&gt;
    &lt;td style=&quot;background-color: #eeeeee; color: black;&quot; valign=&quot;top&quot;&gt;smtp_port&lt;/td&gt;
    &lt;td style=&quot;background-color: #eeeeee; color: black;&quot; valign=&quot;top&quot;&gt;&quot;25&quot;&lt;/td&gt;
    &lt;td style=&quot;background-color: #eeeeee;&quot; valign=&quot;top&quot;&gt;(&lt;b&gt;Windows&lt;/b&gt;) The SMTP port number. &lt;/td&gt;
   
  &lt;/tr&gt;
&lt;tr style=&quot;background-color: white;&quot;&gt;
    &lt;td style=&quot;color: black;&quot; valign=&quot;top&quot;&gt;sendmail_from&lt;/td&gt;
    &lt;td style=&quot;color: black;&quot; valign=&quot;top&quot;&gt;NULL&lt;/td&gt;
    &lt;td valign=&quot;top&quot;&gt;(&lt;b&gt;Windows&lt;/b&gt;)Specifies the &quot;from&quot; address to be used 
 in email sent from PHP&lt;/td&gt;
   
  &lt;/tr&gt;
&lt;tr style=&quot;background-color: white;&quot;&gt;
    &lt;td style=&quot;background-color: #eeeeee; color: black;&quot; valign=&quot;top&quot;&gt;sendmail_path&lt;/td&gt;
    &lt;td style=&quot;background-color: #eeeeee; color: black;&quot; valign=&quot;top&quot;&gt;NULL&lt;/td&gt;
    &lt;td style=&quot;background-color: #eeeeee;&quot; valign=&quot;top&quot;&gt;(&lt;b&gt;Linux&lt;/b&gt;): Specifies where the sendmail program can be found ( /usr/sbin/sendmail 
 or /usr/lib/sendmail)&lt;/td&gt;
   
  &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;a href=&quot;http://hirengprajapati.blogspot.in/2012/09/php-simple-e-mail-script.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Php mail() Example&lt;/b&gt;&lt;/a&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/2184221443075652912/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/2184221443075652912' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/2184221443075652912'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/2184221443075652912'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/e-mail-confuguration-in-php.html' title='E-mail confuguration in Php'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-2875337200170060465</id><published>2012-09-03T23:26:00.000-07:00</published><updated>2012-09-03T23:26:29.507-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Configuration Php"/><category scheme="http://www.blogger.com/atom/ns#" term="Installation Php"/><title type='text'>Most Frequently used php configuration directives : php.ini</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Below are the most frequntly used php directives.&lt;br /&gt;
You have to change &lt;b&gt;php.ini&lt;/b&gt; file for making confuguration level setting.&lt;br /&gt;
This just means &lt;b&gt;changing these directive’s option and value&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Php.ini&lt;/b&gt; file is configuration file for php, You can find the location of &lt;b&gt;php.ini&lt;/b&gt; file from&lt;br /&gt;
Go to&lt;b&gt; http://locahost/xamp&lt;/b&gt; and the click&lt;b&gt; phpinfo()&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;1) &lt;span style=&quot;color: blue;&quot;&gt;short_open_tag&lt;/span&gt; = Off&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp;This will not allow the shout tags like &lt;b&gt;, if this is set off&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;2) &lt;span style=&quot;color: blue;&quot;&gt;max_execution_time&lt;/span&gt; = 30 &lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Maximum execution time of th script, in seconds&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;3) &lt;span style=&quot;color: blue;&quot;&gt;error_reporting&lt;/span&gt; = E_ALL &amp;amp; ~E_NOTICE &amp;amp; ~E_STRICT&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
This shows all errors, except coding standards warnings. Some more examples for 
&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;error_reporting setting:&lt;/pre&gt;
- Show all errors, except for notices and coding standards warnings&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;error_reporting = E_ALL &amp;amp; ~E_NOTICE&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
- Show all errors, except for notices&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;error_reporting = E_ALL &amp;amp; ~E_NOTICE | E_STRICT&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
- Show only errors&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;error_reporting= E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;4) &lt;span style=&quot;color: blue;&quot;&gt;display_errors&lt;/span&gt; = On&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Print errors (as a part of the output).  For production web sites turn this feature off, and use error logging instead (see below). &lt;b&gt; Keeping display_errors enabled on a production web site may reveal security information to end users&lt;/b&gt;, such as &lt;b&gt;file paths on your Web server&lt;/b&gt;, &lt;b&gt;your database schema&lt;/b&gt; or &lt;b&gt;other information.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;5) &lt;span style=&quot;color: blue;&quot;&gt;log_errors&lt;/span&gt; = On&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Create Log of errors into a log file (&lt;b&gt;server-specific log&lt;/b&gt;, or &lt;b&gt;error_log&lt;/b&gt;). You should use&lt;b&gt; error logging&lt;/b&gt; in place of &lt;b&gt;error displaying &lt;/b&gt;on production web sites.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;6)&lt;span style=&quot;color: blue;&quot;&gt; register_globals&lt;/span&gt; = Off&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
You should do your best to write your scripts so that they do not require &lt;b&gt;register_globals&lt;/b&gt; to be on.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Using form variables as globals can easily lead to possible security problems, if the code is not very well. Making register_global&amp;nbsp; on can make securitry hole.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;7) &lt;span style=&quot;color: blue;&quot;&gt;memory_limit &lt;/span&gt;= 128M&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This sets the maximum amount of memory in bytes that a script is allowed to allocate. This helps prevent poorly written scripts for eating up all available memory on a server.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;8) &lt;span style=&quot;color: blue;&quot;&gt;post_max_size &lt;/span&gt;= 8M&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Maximum &lt;b&gt;size of POST data &lt;/b&gt;that PHP will accept. &lt;b&gt;In the above example Post max size is 8MB&lt;/b&gt;.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This setting also affects file upload. &lt;b&gt;To upload large files, this value must be larger than upload_max_filesize&lt;/b&gt;.   If memory limit is set by your configure script, memory_limit also affects file uploading. Generally , &lt;b&gt;memory_limit&lt;/b&gt; should be more than &lt;b&gt;post_max_size&lt;/b&gt; .&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;9) &lt;span style=&quot;color: blue;&quot;&gt;file_uploads&lt;/span&gt; = On&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Allow HTTP file uploads or not.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;10) &lt;span style=&quot;color: blue;&quot;&gt;upload_max_filesize&lt;/span&gt; = 2M&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Maximum allowed size for uploaded files. &lt;b&gt;Default is&amp;nbsp; 2MB.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h2&gt;
&lt;b&gt;11) &lt;span style=&quot;color: blue;&quot;&gt;allow_url_fopen&lt;/span&gt; = On&lt;/b&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Allow the treatment of URLs (like &lt;b&gt;http://&lt;/b&gt; or &lt;b&gt;ftp://&lt;/b&gt;) as files if on.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/2875337200170060465/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/2875337200170060465' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/2875337200170060465'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/2875337200170060465'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/most-frequently-used-php-configuration.html' title='Most Frequently used php configuration directives : php.ini'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-1191303526283426808</id><published>2012-09-03T06:16:00.001-07:00</published><updated>2012-09-03T06:16:46.599-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Php"/><title type='text'>Output Buffer in Php</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h3 class=&quot;dynamic&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
What is the output buffer?&lt;/span&gt;&lt;/h3&gt;
If you output some html or javascript code or use echo or print within php, this information is being sent to the browser. If you use the output buffer this information is first stored on the server until either the script has finished executing or you performed some kind of action on the buffer.&lt;br /&gt;
&lt;br /&gt;
We will now look at how to use the output buffer and what we can do with it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 class=&quot;dynamic&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
Starting Output Buffer&lt;/span&gt;&lt;/h3&gt;
You have to start the output buffer before anything is sent to the browser. So one of the ways to ensure that is starting it right after you opened the php tag.
Example:

&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&amp;lt;?php
&lt;span style=&quot;color: blue;&quot;&gt;ob_start&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;()&lt;/span&gt;;&lt;/b&gt;&lt;/pre&gt;
Make sure that there is really nothing before the php opening tag. Even a space can cause errors.
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 class=&quot;dynamic&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
Send Output Buffer to Browser&lt;/span&gt;&lt;/h3&gt;
If at any time you wish to send the content of the buffer to the browser you can do this with the following line.&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;ob_flush&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;()&lt;/span&gt;;&lt;/b&gt;&lt;b&gt;
&lt;/b&gt;&lt;/pre&gt;
After this point however the output buffer will continue to buffer the content which is send to the browser. If you which to simply send the content of the buffer and stop using it you can do this with the following code.&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;ob_end_flush&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;()&lt;/span&gt;;&lt;/b&gt;&lt;b&gt;
&lt;/b&gt;&lt;/pre&gt;
&lt;h3 class=&quot;dynamic&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
Delete Output Buffer&lt;/span&gt;&lt;/h3&gt;
In some instances you might wish to delete whatever is stored in the output buffer and build up a new page. You can do this by using the following command.&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;ob_clean&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;()&lt;/span&gt;;&lt;/b&gt;&lt;b&gt;
&lt;/b&gt;&lt;/pre&gt;
Just like the &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;ob_flush&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;()&lt;/span&gt;;&lt;/b&gt; command, the output buffer would continue buffering the content which is sent to the browser. The command to delete the buffer and stop it is
&lt;br /&gt;
&lt;strong&gt;&lt;span style=&quot;color: blue;&quot;&gt;ob_end_clean&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;()&lt;/span&gt;;&lt;/strong&gt;
&lt;br /&gt;
&lt;strong&gt;&lt;br /&gt;&lt;/strong&gt;
&lt;br /&gt;
&lt;h3 class=&quot;dynamic&quot;&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;
Get Output Buffer Content&lt;/span&gt;&lt;/h3&gt;
If you started the output buffer you can get the content of it at any time (&lt;b&gt;unless you have deleted it or sent it to the browser of course&lt;/b&gt;). This is done by the following line
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #bf9000;&quot;&gt;$var&lt;/span&gt; = &lt;/b&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;b&gt;ob_get_contents&lt;/b&gt;&lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;()&lt;/span&gt;;&lt;/b&gt;&lt;b&gt;
&lt;/b&gt;&lt;/pre&gt;
This means that everything you echo or would be sent otherwise to the browser between this line and the &lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;ob_start&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;()&lt;/span&gt;; will now be in &lt;b&gt;$var&lt;/b&gt;.

Now you may wonder what you can do with this. Well there are multiple things. You could create a templating system for example. You could create a file in which you have all the look and feel but without content. Where you would usually place content like in the title or a menu you would place tokens.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Example:
&lt;/h2&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;&amp;lt;title&amp;gt;&lt;span style=&quot;color: #bf9000;&quot;&gt;[%TITLE%]&lt;/span&gt;&amp;lt;/title&amp;gt;

&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&lt;span style=&quot;color: #bf9000;&quot;&gt;MENU&lt;/span&gt;

&lt;span style=&quot;color: #bf9000;&quot;&gt;CONTENT&lt;/span&gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/b&gt;
&lt;strong&gt;
&lt;/strong&gt;&lt;/pre&gt;
&lt;br /&gt;
So in the above example we have 3 placeholders. one for the title, menu and for content. And this is the way we can use the template with the output buffer.
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&amp;lt;?php

&lt;span style=&quot;color: blue;&quot;&gt;ob_start&lt;/span&gt;();

include(&#39;&lt;span style=&quot;color: blue;&quot;&gt;template.php&lt;/span&gt;&#39;);
$title = &#39;&lt;span style=&quot;color: blue;&quot;&gt;Hello World&lt;/span&gt;&#39;;

&lt;span style=&quot;color: #bf9000;&quot;&gt;$menu &lt;/span&gt;= &#39;&amp;lt;a href=&quot;&lt;span style=&quot;color: blue;&quot;&gt;index.php&lt;/span&gt;&quot;&amp;gt;Home&amp;lt;/a&amp;gt; | &amp;lt;a href=&quot;about.php&quot;&amp;gt;About us&amp;lt;/a&amp;gt;&#39;;

&lt;span style=&quot;color: #bf9000;&quot;&gt;$content&lt;/span&gt; = &#39;&amp;lt;h1&amp;gt;Hello World&amp;lt;/h1&amp;gt; This is a simple test to show how the templating system works&#39;;

&lt;span style=&quot;color: #bf9000;&quot;&gt;$var&lt;/span&gt; = &lt;span style=&quot;color: blue;&quot;&gt;ob_get_contents&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;()&lt;/span&gt;;
&lt;span style=&quot;color: blue;&quot;&gt;ob_clean&lt;/span&gt;&lt;span style=&quot;color: #38761d;&quot;&gt;()&lt;/span&gt;;

&lt;span style=&quot;color: #bf9000;&quot;&gt;echo &lt;/span&gt;$var;

?&amp;gt;&lt;/b&gt;
&lt;b&gt;
&lt;/b&gt;&lt;/pre&gt;
&lt;br /&gt;
As you can see once you have the content you can do whatever you wish with it. Here are some ideas what you could do:
&lt;br /&gt;
&lt;ul&gt;

&lt;br /&gt;
&lt;li&gt;Delete all the line breaks and spaces between the tags to reduce the filesize&lt;/li&gt;
&lt;li&gt;Make sure that all links have the full path ie with&lt;b&gt; http://www.domain.com&lt;/b&gt; and not only index.php&lt;/li&gt;
&lt;li&gt;Add a nofollow to all links to add external sites (&lt;b&gt;SEO technique&lt;/b&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/1191303526283426808/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/1191303526283426808' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/1191303526283426808'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/1191303526283426808'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/output-buffer-in-php.html' title='Output Buffer in Php'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-4223987486424768462</id><published>2012-09-03T00:30:00.000-07:00</published><updated>2012-09-03T01:44:48.307-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Learn Php Basics"/><title type='text'>Php Arrays</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;An array is a special variable&lt;/b&gt;, which can store multiple values in one single variable.
&lt;br /&gt;
There are three kind of arrays in php:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Numeric array&lt;/b&gt; - An array with a numeric index&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Associative array&lt;/b&gt; - An array where each ID key is associated with a value&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Multidimensional array&lt;/b&gt; -Array elements can contain one or more array.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Numeric Array&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Numeric Array can be created by two ways.&lt;/span&gt;&lt;/div&gt;
&lt;b&gt;1.&lt;/b&gt; Auto index.In this index will assigned automatically.&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;$&lt;b&gt;bikes&amp;nbsp;&lt;/b&gt;= array(&quot;&lt;span style=&quot;color: blue;&quot;&gt;Hero&lt;/span&gt;&quot;,&quot;&lt;span style=&quot;color: blue;&quot;&gt;Bajaj&lt;/span&gt;&quot;,&quot;&lt;span style=&quot;color: blue;&quot;&gt;Yamaha&lt;/span&gt;&quot;);&lt;/pre&gt;
&lt;b&gt;2.&lt;/b&gt; We can assign index manually also :
&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;$bikes&lt;/b&gt;[0]=&quot;&lt;span style=&quot;color: blue;&quot;&gt;Hero&lt;/span&gt;&quot;;
&lt;b&gt;$bikes&lt;/b&gt;[1]=&quot;&lt;span style=&quot;color: blue;&quot;&gt;Bajaj&lt;/span&gt;&quot;;
&lt;b&gt;$bikes&lt;/b&gt;[2]=&quot;&lt;span style=&quot;color: blue;&quot;&gt;Yamaha&lt;/span&gt;&quot;;
&lt;/pre&gt;
&lt;h2&gt;
&lt;/h2&gt;
&lt;h2&gt;
Associative Arrays&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;In associative array there is a key value pair&lt;/span&gt;&lt;/div&gt;
With associative arrays we can use the values as keys and assign values 
to them.&lt;br /&gt;
&lt;h3&gt;
Example :&lt;/h3&gt;
In this example we use an array to assign ages to the different persons:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;$personages&lt;/b&gt; = &lt;b&gt;array(&lt;/b&gt;&quot;Sujal&quot;=&amp;gt;&lt;span style=&quot;color: blue;&quot;&gt;32&lt;/span&gt;, &quot;Mitesh&quot;=&amp;gt;&lt;span style=&quot;color: blue;&quot;&gt;30&lt;/span&gt;, &quot;Hiren&quot;=&amp;amp;gt&lt;span style=&quot;color: blue;&quot;&gt;;34&lt;/span&gt;&lt;b&gt;)&lt;/b&gt;;

&lt;b&gt;$personages&lt;/b&gt;[&#39;Sujal&#39;] = &quot;&lt;span style=&quot;color: blue;&quot;&gt;32&lt;/span&gt;&quot;;
&lt;b&gt;$personages&lt;/b&gt;[&#39;Mitesh&#39;] = &quot;&lt;span style=&quot;color: blue;&quot;&gt;30&lt;/span&gt;&quot;;
&lt;b&gt;$personages&lt;/b&gt;[&#39;Hiren&#39;] = &quot;&lt;span style=&quot;color: blue;&quot;&gt;34&lt;/span&gt;&quot;;&lt;/pre&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;/h2&gt;
&lt;h2&gt;
Multidimensional Arrays&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Multidimentional array means each element of array can also be a array.&lt;/span&gt;&lt;/div&gt;
&lt;h3&gt;
Example :&lt;/h3&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;$Arrayresult = Array&lt;/b&gt;
&lt;b&gt;(&lt;/b&gt;
[&lt;span style=&quot;color: blue;&quot;&gt;Admin&lt;/span&gt;] =&amp;gt; &lt;b&gt;Array&lt;/b&gt;
&amp;nbsp;&amp;nbsp;(
&amp;nbsp;&amp;nbsp;[0] =&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;Sujal&lt;/span&gt;
&amp;nbsp;&amp;nbsp;[1] =&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;Mitesh&lt;/span&gt;
&amp;nbsp;&amp;nbsp;[2] =&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;Hiren&lt;/span&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;)&lt;/b&gt;
[&lt;span style=&quot;color: blue;&quot;&gt;Receptionist&lt;/span&gt;] =&amp;gt; &lt;b&gt;Array&lt;/b&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;(&lt;/b&gt;
&amp;nbsp;&amp;nbsp;[0] =&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;Glenn&lt;/span&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;)&lt;/b&gt;
[&lt;span style=&quot;color: blue;&quot;&gt;Staff&lt;/span&gt;] =&amp;gt; &lt;b&gt;Array&lt;/b&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;(&lt;/b&gt;
&amp;nbsp;&amp;nbsp;[0] =&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;Rahul&lt;/span&gt;
&amp;nbsp;&amp;nbsp;[1] =&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;Sandhya&lt;/span&gt;
&amp;nbsp;&amp;nbsp;[2] =&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;Suraj&lt;/span&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp;)&lt;/b&gt;
&lt;b&gt;)&lt;/b&gt;&lt;/pre&gt;
We can access staff details by&amp;nbsp;&lt;b&gt;$&lt;/b&gt;&lt;b&gt;Arrayresult[&#39;&lt;/b&gt;staff&lt;b&gt;&#39;][&lt;/b&gt;0&lt;b&gt;]&lt;/b&gt;&amp;nbsp;&amp;nbsp;or
&lt;b&gt;$&lt;/b&gt;&lt;b&gt;Arrayresult[&#39;&lt;/b&gt;staff&lt;b&gt;&#39;][&lt;/b&gt;1&lt;b&gt;]&lt;/b&gt;&amp;nbsp;or&amp;nbsp;
&lt;b&gt;$&lt;/b&gt;&lt;b&gt;Arrayresult[&#39;&lt;/b&gt;staff&lt;b&gt;&#39;][&lt;/b&gt;2&lt;b&gt;]&lt;/b&gt;&amp;nbsp;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/4223987486424768462/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/4223987486424768462' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/4223987486424768462'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/4223987486424768462'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-arrays.html' title='Php Arrays'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-5066810626204945742</id><published>2012-09-01T06:17:00.002-07:00</published><updated>2012-09-01T06:21:53.081-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Learn Php Basics"/><title type='text'>Php $_POST &amp; $_REQUEST variable</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2&gt;
The $_POST Variable&lt;/h2&gt;
The &lt;b&gt;$_POST &lt;/b&gt;variable is used to collect values from a form which are sent using post method.&lt;br /&gt;
Information sent with the POST method is not visible to addressbar and it has no limitations&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt; There is default &lt;b&gt;8 Mb&lt;/b&gt; max size for the POST method it can be changed by setting the &lt;b&gt;post_max_size&lt;/b&gt; in the php.ini file).&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Example :&lt;/h3&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&amp;lt;form action=&quot;target.php&quot; method=&quot;&lt;span style=&quot;color: blue;&quot;&gt;post&lt;/span&gt;&quot;&amp;gt;

&lt;span style=&quot;color: blue;&quot;&gt;Name:&lt;/span&gt; &amp;lt;input type=&quot;text&quot; name=&quot;&lt;span style=&quot;color: blue;&quot;&gt;username&lt;/span&gt;&quot; /&amp;gt;

&lt;span style=&quot;color: blue;&quot;&gt;Age:&lt;/span&gt; &amp;lt;input type=&quot;text&quot; name=&quot;&lt;span style=&quot;color: blue;&quot;&gt;country&lt;/span&gt;&quot; /&amp;gt;

&amp;lt;input type=&quot;&lt;span style=&quot;color: blue;&quot;&gt;submit&lt;/span&gt;&quot; /&amp;gt;&lt;/b&gt;
&lt;b&gt;&amp;lt;/form&amp;gt;&lt;/b&gt;&amp;nbsp;&lt;/pre&gt;
When the user clicks the &quot;Submit&quot; button, the addressbar will be 
like this:&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;http://www.test.com/target.php&lt;/b&gt;&amp;nbsp;&lt;/pre&gt;
The &quot;target.php&quot; file can now use the &lt;b&gt;$_POST&lt;/b&gt; variable to collect form data 
(the names of the form fields will automatically be the keys in the &lt;b&gt;$_POST&lt;/b&gt; 
array):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Welcome &lt;/span&gt;&lt;/b&gt;&lt;b&gt;&amp;lt;?php &lt;span style=&quot;color: #bf9000;&quot;&gt;echo &lt;/span&gt;$_POST[&quot;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;username&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&quot;]; ?&amp;gt;!&amp;lt;br /&amp;gt;

&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;You are&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;from &lt;/span&gt;&lt;/b&gt;&lt;b&gt; &amp;lt;?php &lt;span style=&quot;color: #bf9000;&quot;&gt;echo &lt;/span&gt;$_POST[&quot;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;country&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&quot;]; ?&amp;gt; &lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;country&lt;/span&gt;&lt;/b&gt;&lt;b&gt;.&lt;/b&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;The PHP $_REQUEST Variable&lt;/span&gt;&lt;/h2&gt;
The&amp;nbsp; &lt;b&gt;$_REQUEST&lt;/b&gt; variable contain all values of&amp;nbsp; &lt;b&gt;$_GET&lt;/b&gt;, &lt;b&gt;$_POST&lt;/b&gt;, and &lt;b&gt;$_COOKIE&lt;/b&gt;.&lt;br /&gt;
The &lt;b&gt;$_REQUEST&lt;/b&gt; variable can be used to collect form data sent 
with both the &lt;b&gt;GET &lt;/b&gt;and &lt;b&gt;POST &lt;/b&gt;methods.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
Example :&lt;/h3&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Welcome &lt;/span&gt;&amp;lt;?php &lt;span style=&quot;color: #bf9000;&quot;&gt;echo &lt;/span&gt;$_REQUEST[&quot;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;username&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&quot;]; ?&amp;gt;!&amp;lt;br /&amp;gt;

&lt;span style=&quot;color: blue;&quot;&gt;You are&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;from &lt;/span&gt;&amp;lt;?php &lt;span style=&quot;color: #bf9000;&quot;&gt;echo &lt;/span&gt;$_REQUEST[&quot;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;country&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&quot;]; ?&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;country&lt;/span&gt;.&lt;/b&gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/5066810626204945742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/5066810626204945742' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/5066810626204945742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/5066810626204945742'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-post-request-variable.html' title='Php $_POST &amp; $_REQUEST variable'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8859447625947777020.post-7794938755988406123</id><published>2012-09-01T05:57:00.000-07:00</published><updated>2012-09-01T05:57:10.153-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Learn Php Basics"/><title type='text'>Php $_GET variable</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2&gt;
&amp;nbsp; &lt;/h2&gt;
The &lt;b&gt;$_GET&lt;/b&gt; variable is used To collect values in a form with form method &quot;get&quot;&lt;br /&gt;
Information sent from the GET method is visible in url and displayed in the browser&#39;s address bar.&lt;br /&gt;
&lt;br /&gt;
The get method is not suitable for very large variable values. 
It should not be used with values exceeding &lt;b&gt;2000 &lt;/b&gt;characters.&lt;br /&gt;
&lt;h3&gt;
Example&lt;/h3&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&amp;lt;form action=&quot;&lt;span style=&quot;color: blue;&quot;&gt;target.php&lt;/span&gt;&quot; method=&quot;&lt;span style=&quot;color: blue;&quot;&gt;get&lt;/span&gt;&quot;&amp;gt;&lt;/b&gt;

&lt;b&gt;&lt;span style=&quot;color: #bf9000;&quot;&gt;UserName&lt;/span&gt;: &amp;lt;input type=&quot;&lt;span style=&quot;color: blue;&quot;&gt;text&lt;/span&gt;&quot; name=&quot;&lt;span style=&quot;color: blue;&quot;&gt;username&lt;/span&gt;&quot; /&amp;gt;&lt;/b&gt;

&lt;b&gt;&lt;span style=&quot;color: #bf9000;&quot;&gt;Country&lt;/span&gt;: &amp;lt;input type=&quot;&lt;span style=&quot;color: blue;&quot;&gt;text&lt;/span&gt;&quot; name=&quot;&lt;span style=&quot;color: blue;&quot;&gt;country&lt;/span&gt;&quot; /&amp;gt;&lt;/b&gt;

&lt;b&gt;&amp;lt;input type=&quot;&lt;span style=&quot;color: blue;&quot;&gt;submit&lt;/span&gt;&quot; /&amp;gt;&lt;/b&gt;

&lt;b&gt;&amp;lt;/form&amp;gt;

&lt;/b&gt;
&lt;b&gt;When the user press the &quot;Submit&quot; button, the URL sent to the 
server look like below:&lt;/b&gt;

&lt;b&gt;http://www.test.com/target.php?username=&lt;span style=&quot;color: blue;&quot;&gt;Hiren&lt;/span&gt;&amp;amp;country=&lt;span style=&quot;color: blue;&quot;&gt;india&lt;/span&gt;

&lt;/b&gt;
&lt;/pre&gt;
The &quot;target.php&quot; file can now use the&lt;b&gt; $_GET&lt;/b&gt; variable to collect form data 
(the names of the form fields will automatically be the keys in the &lt;b&gt;$_GET&lt;/b&gt; 
array):&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;Welcome &lt;/span&gt;&amp;lt;?php &lt;span style=&quot;color: #bf9000;&quot;&gt;echo &lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;$_GET&lt;/span&gt;[&quot;username&quot;]; ?&amp;gt;.&lt;/b&gt;

&lt;b&gt;&lt;span style=&quot;color: blue;&quot;&gt;You are&lt;/span&gt; &lt;span style=&quot;color: blue;&quot;&gt;from &lt;/span&gt;&amp;lt;?php &lt;span style=&quot;color: #bf9000;&quot;&gt;echo &lt;/span&gt;$_GET[&quot;country&quot;]; ?&amp;gt; &lt;span style=&quot;color: blue;&quot;&gt;country!&lt;/span&gt;&lt;/b&gt;&lt;/pre&gt;
&lt;h2&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;When should use&amp;nbsp; &quot;get&quot; method?&lt;/span&gt;&lt;/h2&gt;
When using &lt;b&gt;method=&quot;get&quot;&lt;/b&gt; in HTML forms, all variable names and values are displayed in the addressbar.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note:&lt;/b&gt; get method should not be used when sending sensitive information like password!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://hirengprajapati.blogspot.com/feeds/7794938755988406123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/8859447625947777020/7794938755988406123' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/7794938755988406123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8859447625947777020/posts/default/7794938755988406123'/><link rel='alternate' type='text/html' href='http://hirengprajapati.blogspot.com/2012/09/php-get-variable.html' title='Php $_GET variable'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/02783392947172339477</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>