<?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: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-727499088252185747</id><updated>2012-02-02T20:12:24.423-08:00</updated><category term='PHP'/><category term='MySql Basics'/><category term='MySql'/><category term='PHP Language'/><category term='PHP Basics'/><category term='PHP Reference'/><category term='HTML Form'/><category term='Strings'/><category term='PHP Strings'/><category term='HTML'/><title type='text'>PHP MySql</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://phpnmysql.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/727499088252185747/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://phpnmysql.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>H. P.</name><uri>http://www.blogger.com/profile/08808176886063562208</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-727499088252185747.post-9042903795995000222</id><published>2007-12-14T08:02:00.000-08:00</published><updated>2008-11-22T05:55:47.368-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP Strings'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP Basics'/><category scheme='http://www.blogger.com/atom/ns#' term='Strings'/><title type='text'>PHP Strings Common PHP String Functions  Substring Examples</title><content type='html'>&lt;h4&gt;PHP String&lt;/h4&gt;
&lt;div style="text-align: justify;"&gt;
A string is an important data type in any programming language, used to manipulate informative data using different methods. PHP strings can be of any length, since there is no limits to the size of strings in PHP. The PHP strings can be specified using either single quote (ex. 'This is test string') or using double quotes (ex. "test string"). As compared with double quoted strings in single quoted PHP string&lt;b&gt;&lt;i&gt; variable will not be parsed and such string  have only one escape character, single quote&lt;/i&gt;&lt;/b&gt;. Like any other programming languages, PHP also has some in built string manipulation functions. These PHP functions can directly be used in our code or other powerful functions can be derived using these basic string functionalities. Following is the list of some commonly used PHP functions along with examples.
&lt;/div&gt;

&lt;h4&gt;Finding length of a PHP string using strlen&lt;/h4&gt;
&lt;div style="text-align: justify;"&gt;
The strlen PHP string function is used to find the length of the given string. for example
&lt;pre&gt;
$str = 'test string'; 
$len = strlen('$str');
echo $len; // this will output 11
&lt;/pre&gt;
&lt;/div&gt;

&lt;h4&gt;Checking substring existence using strpos&lt;/h4&gt;
&lt;div style="text-align: justify;"&gt;
PHP string function strpos can be used to check for substring existence. See example below:
&lt;pre&gt;
$str = 'test string';
$sub_str = 'str';
if (strpos($str, $sub_str) === false) 
 echo "Substring not found";
else
 echo "Substring exist in given string";
&lt;/pre&gt;
Note the use of === operator because == will not work as expected since the return position can be 0 (start of string).&lt;br&gt;
The offset value can be used here to specify from where to start searching. see example below:
&lt;pre&gt;
$str = 'abcdefabcdef';
echo strpos($str, 'a', 1); // will print 6 not 0
&lt;/pre&gt;
&lt;/div&gt;

&lt;h4&gt;Finding occurrence of a string&lt;/h4&gt;
&lt;div style="text-align: justify;"&gt;
The strstr PHP string function is used to find the first occurrence. See below
&lt;pre&gt;
$email = 'user@domain.com';
$domain = strstr($email, '@');
echo $domain; // this will print '@domain.com'
&lt;/pre&gt;
So strstr will return part of the string, starting from the given substring. If given substring does not exist, it will return FALSE.
This string function is case-sensitive. For case-insensitive searches stristr is used , see below:
&lt;pre&gt;
$domain = stristr('USER@EXAMPLE.com', 'e');
echo $domain; // This will print ER@EXAMPLE.com
&lt;/pre&gt;
Function strrchr(string str, char chr) is used to find the last occurrence of a character.
This function returns the portion of string which starts at the last occurrence of given character and goes up to the end. see example below:
&lt;pre&gt;
echo strrchr("abcdexyz", "e"); // will print exyz
echo substr(strrchr("module.filename.html", "."),1); // will print html
&lt;/pre&gt;
&lt;/div&gt;

&lt;h4&gt;Return part of a string: Substring&lt;/h4&gt;
&lt;div style="text-align: justify;"&gt;
The PHP function &lt;i&gt;substr( string string, int start [, int length])&lt;/i&gt; can be used to return part of a given string specified by
start and length parameters. see examples below:
&lt;pre&gt;
echo substr("abcdef", 1);    // will output "bcdef" , start 1 to end.
echo substr("abcdef", 1, 3); // will output "bcd", 1 to 3
echo substr("abcdef", 0, 4); // will output "abcd"
echo substr("abcdef", 0, 8); // will output "abcdef"
&lt;/pre&gt;
Using curly braces we can also return a character at given position. For example
&lt;pre&gt;
$string = 'abcdef';
echo $string{0}; // will print a
echo $string{3}; // will print d
&lt;/pre&gt;
We can also use negative value of start parameter to return part from the end of string. see examples below:
&lt;pre&gt;
substr("abcdef", -1);    // returns "f"
substr("abcdef", -2);    // returns "ef"
substr("abcdef", -3, 1); // returns "d"
&lt;/pre&gt;
Also negative value of length parameter can be used. In this case it will omit that many characters from the end of the string. See below:
&lt;pre&gt;
echo substr("abcdef", 0, -1);  // will omit 1 char from the end and returns "abcde"
echo substr("abcdef", 2, -1);  // returns "cde"
echo substr("abcdef", 4, -4);  // returns ""
echo substr("abcdef", -3, -1); // returns "de"
&lt;/pre&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/727499088252185747-9042903795995000222?l=phpnmysql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpnmysql.blogspot.com/feeds/9042903795995000222/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=727499088252185747&amp;postID=9042903795995000222' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/727499088252185747/posts/default/9042903795995000222'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/727499088252185747/posts/default/9042903795995000222'/><link rel='alternate' type='text/html' href='http://phpnmysql.blogspot.com/2007/12/common-php-string-functions-examples.html' title='PHP Strings Common PHP String Functions  Substring Examples'/><author><name>H. P.</name><uri>http://www.blogger.com/profile/08808176886063562208</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-727499088252185747.post-72921851178136927</id><published>2007-04-18T07:34:00.000-07:00</published><updated>2008-08-12T08:14:45.070-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML Form'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP Basics'/><category scheme='http://www.blogger.com/atom/ns#' term='HTML'/><title type='text'>PHP HTML Forms Using HTML Form Fields Hidden Radio Buttons Checkboxes</title><content type='html'>&lt;div style="text-align: justify;"&gt;
PHP is widely used today as server side scripting language. It is mostly used to develop interactive web sites and can easily be embedded in HTML. The interaction between user/browser and the server is carried out using the HTML forms. One of the most powerful features of PHP is the way it handles HTML forms. This tutorial explain using HTML form fields like Input, Hidden, Radio Buttons, Check boxes etc. The basic concept that is important to understand is that any form field values in a form will automatically be available to your PHP scripts. HTML forms can be submitted to the handling PHP script using either GET or POST method.
See example below:
&lt;br&gt;&lt;textarea rows=4 cols=60&gt;
&lt;form action="action.php" method=POST&gt;
 &lt;input type="text" name="first_name"&gt;
 &lt;input type="text" name="last_name"&gt;
&lt;/form&gt;
&lt;/textarea&gt;&lt;br&gt;
When we submit above form autoglobal $_POST['first_name'] and $_POST['last_name'] automatically available to the form handling PHP script. Similarly if GET method is used then $_GET['first_name'] and $_GET['last_name'] is available. Following example shows how we can access values in handling PHP script i.e. in action.php
&lt;br&gt;&lt;textarea rows=3 cols=60&gt;
 echo "Your First Name is: ".$_POST['first_name'];
 echo "Your Last Name is: ".$_POST['last_name'];
&lt;/textarea&gt;&lt;br&gt;
There are various types of input elements are used in HTML form. Following is the list of such elements used to accept inputs from user/broswer that needs to be sent to the web server for further processing:
&lt;ul&gt;
&lt;li&gt;&lt;a href="#text"&gt;Text, hidden and password type inputs&lt;/a&gt;
&lt;li&gt;&lt;a href="#textarea"&gt;Textarea multiline text element&lt;/a&gt;
&lt;li&gt;&lt;a href="#select"&gt;Select (Pull Down menu) and Select multiple options&lt;/a&gt;
&lt;li&gt;&lt;a href="#radio"&gt;HTML field Radio buttons&lt;/a&gt;
&lt;li&gt;&lt;a href="#check"&gt;Check Boxes type fields&lt;/a&gt;
&lt;li&gt;&lt;a href="#submiting"&gt;Submiting form&lt;/a&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;h4&gt;&lt;a name="text"&gt;Text input, Hidden input and Password type input fields&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
This input form element can be used for a single lime text input from the user. For example user first name, user e-mail, phone numbers etc. The syntax in HTML form is as below
&lt;br&gt;&lt;textarea rows=3 cols=60&gt;
&lt;input type="text" name="username"&gt;
&lt;input type="text" name="email"&gt;
&lt;/textarea&gt;&lt;br&gt;

This will display an input box in the browser and the values of this element canbe accessed at the form handling php script by following.
&lt;br&gt;&lt;textarea rows=3 cols=60&gt;
&lt;?php echo "User Name:".$_POST['username']; ?&gt;
&lt;/textarea&gt;&lt;br&gt;

&lt;b&gt;Password type&lt;/b&gt; The defulat type of HTML input element is text. The special password type of input can be used as following
&lt;br&gt;&lt;textarea rows=3 cols=60&gt;
&lt;input type="password" name="password"&gt;
&lt;/textarea&gt;&lt;br&gt;

and can be accessed in PHP similar to above input element.
&lt;br&gt;&lt;textarea rows=3 cols=60&gt;
&lt;?php echo "The Password is:".$_POST['password']; ?&gt;
&lt;/textarea&gt;&lt;br&gt;

&lt;b&gt;Hidden type&lt;/b&gt; The hidden field is used to send information from browser to the server without having to input it. Typically this is used to send some logical data that has nothing to do with user but used at the server in PHP program logic. For example state, action, or passing the result to the other module etc. Please note that you encode the value using htmlspecialchars() function.
&lt;br&gt;&lt;textarea rows=3 cols=60&gt;
&lt;input type="hidden" name="action" value="?php echo htmlspecialchars('step2'); ?"&gt;
&lt;/textarea&gt;&lt;br&gt;

and the value of this field can be accessed in PHP by following.
&lt;br&gt;&lt;textarea rows=3 cols=60&gt;
&lt;?php echo "The Value of action is:".$_POST['action']; ?&gt;
&lt;/textarea&gt;&lt;br&gt;

&lt;/div&gt;

&lt;h4&gt;&lt;a name="textarea"&gt;Textarea multiline text input HTML form element in PHP&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
This form element can be used for a multi-line text input from the user. For example product description. The syntax is as below.
&lt;br&gt;&lt;textarea rows=3 cols=60&gt;
&lt;textarea name="description" rows="5" cols="50"&gt;&lt;/textarea&gt;
&lt;/textarea&gt;&lt;br&gt;

This will display a multi-line input area in the browser and the size can be controlled using rows and cols tag. The text value input by user can be accessed in PHP by following
&lt;br&gt;&lt;textarea rows=3 cols=60&gt;
&lt;?php echo "Product Description:".$_POST['description']; ?&gt;
&lt;/textarea&gt;&lt;br&gt;
&lt;/div&gt;

&lt;h4&gt;&lt;a name="select"&gt;Select (Pull Down menu) and Select multiple options in PHP&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
This type of HTML form element is used to allow user to select from multiple choices. For example selecting a month or a day. The html syntax is as below.
&lt;br&gt;&lt;textarea rows=7 cols=60&gt;
&lt;select name="year"&gt;
&lt;option value="2004"&gt;2004&lt;/option&gt;
&lt;option value="2005"&gt;2005&lt;/option&gt;
&lt;option value="2006"&gt;2006&lt;/option&gt;
&lt;option value="2007"&gt;2007&lt;/option&gt;
&lt;option value="2008"&gt;2008&lt;/option&gt;
&lt;/select&gt;
&lt;/textarea&gt;&lt;br&gt;

The value of selected choice can be accessed in form handling PHP script as following
&lt;br&gt;&lt;textarea rows=2 cols=60&gt;
&lt;?php echo "Selected Year is:".$_POST['year']; ?&gt;
&lt;/textarea&gt;&lt;br&gt;

The variation to this allows user to select multiple choices from the given options.
This can be done by following select multiple syntax
&lt;br&gt;&lt;textarea rows=8 cols=60&gt;
&lt;select multiple name="colors[]" size="4"&gt;
&lt;option value="Red"&gt;Red
&lt;option value="Yellow"&gt;Yellow
&lt;option value="Blue"&gt;Blue
&lt;option value="Green"&gt;Green
&lt;option value="White"&gt;White
&lt;option value="Black"&gt;Black
&lt;/select&gt;
&lt;/textarea&gt;&lt;br&gt;

The size tag can be used to control how many rows should be visible. And note the use of '[]' following the name of the select box. This will denote that it is an array and the choices can be accessed in form handling PHP script by following.
&lt;br&gt;&lt;textarea rows=8 cols=60&gt;
&lt;?php
foreach ($_POST['colors'] as $key =&gt; $value) {
echo "Key: $key; Value: $value&lt;br&gt;";
}
?&gt;
If Red and Green is selected then above code will print
0: Red
1: Green
&lt;/textarea&gt;&lt;br&gt;

&lt;/div&gt;

&lt;h4&gt;&lt;a name="radio"&gt;Radio buttons HTML form element&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
Radio button in HTML form is an alternative method that allows user to select from given options. Unlike drop down menu this is used to create more visibilty in the input form.
&lt;br&gt;&lt;textarea rows=4 cols=60&gt;
&lt;input type="radio" name="colour" value="Red"&gt;Red
&lt;input type="radio" name="colour" value="Orange"&gt;Orange
&lt;input type="radio" name="colour" value="Blue"&gt;Blue
&lt;/textarea&gt;&lt;br&gt;

The value of the selection can be accessed in PHP as following
&lt;br&gt;&lt;textarea rows=2 cols=60&gt;
&lt;?php echo "Selected Color is:".$_POST['colour']; ?&gt;
&lt;/textarea&gt;&lt;br&gt;
&lt;/div&gt;

&lt;h4&gt;&lt;a name="check"&gt;Check Boxes HTML form element&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
This is an alternative way of allowing user to select multiple choices from the given options. Following example show the use of Check Boxes in an HTML form
&lt;br&gt;&lt;textarea rows=6 cols=60&gt;
&lt;input type="checkbox" name="colour[]" value="Red"&gt;Red
&lt;input type="checkbox" name="colour[]" value="Orange"&gt;Orange
&lt;input type="checkbox" name="colour[]" value="Blue"&gt;Blue
&lt;input type="checkbox" name="colour[]" value="Violet"&gt;Violet
&lt;input type="checkbox" name="colour[]" value="Black"&gt;Black
&lt;/textarea&gt;&lt;br&gt;

Again here PHP array is used to access the selected choices from the user.
&lt;br&gt;&lt;textarea rows=10 cols=60&gt;
&lt;?php
 foreach ($_POST['colors'] as $key =&gt; $value) {
  echo "Key: $key; Value: $value&lt;br&gt;";
 }
?&gt;

If Red and Violet is selected then above code will display
0: Red
1: Violet
&lt;/textarea&gt;&lt;br&gt;

&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/727499088252185747-72921851178136927?l=phpnmysql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpnmysql.blogspot.com/feeds/72921851178136927/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=727499088252185747&amp;postID=72921851178136927' title='11 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/727499088252185747/posts/default/72921851178136927'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/727499088252185747/posts/default/72921851178136927'/><link rel='alternate' type='text/html' href='http://phpnmysql.blogspot.com/2007/04/php-beginners-using-html-form-elements.html' title='PHP HTML Forms Using HTML Form Fields Hidden Radio Buttons Checkboxes'/><author><name>H. P.</name><uri>http://www.blogger.com/profile/08808176886063562208</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>11</thr:total></entry><entry><id>tag:blogger.com,1999:blog-727499088252185747.post-6328117519313003091</id><published>2007-04-14T06:57:00.000-07:00</published><updated>2008-08-12T08:00:08.081-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PHP Language'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP Reference'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP Basics'/><title type='text'>PHP Elements PHP Language Reference PHP Quick Reference</title><content type='html'>&lt;div style="text-align: justify;"&gt;
The first step learning any programming language is to know about the language reference elements. PHP is a scripting language that is suited for Web application development and is widely used today. Like any other programing language PHP consists of following basic language elements which are very similar to 'c' language. Here is the quick PHP Language Reference.
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="#variables"&gt;Variables, define and access variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#constants"&gt;Constants&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#data"&gt;Data Types&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#operators"&gt;Operators using operators to create expressions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#control"&gt;Control Structures&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#functions"&gt;Functions creating and using functions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#coding"&gt;Simple PHP Code Example&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;&lt;a name="variables"&gt;PHP Variables&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
Variables in PHP are represented by a $ sign followed by the name of the variable
and is case-sensitive. PHP variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. Examples $a, $user_name, $_xclick.
&lt;ul&gt;
 &lt;li&gt;Assinging value to variable $a = 2; , $b = $a + 2; , $user_name = "White";
 &lt;li&gt;Value by reference: '&amp;' is used to referance a variable. In following examle $b is point to $a&lt;br&gt;
&lt;textarea rows=3 cols=60&gt;
$a = 2;
$b = &amp;$a;
$b = 3; // changing value of $b will change value of $a also.&lt;/textarea&gt;
&lt;/ul&gt;
&lt;b&gt;Predefined variables: PHP Superglobals&lt;/b&gt; are available to any running PHP script. Following
is the list of PHP Predefined variables.
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;$GLOBALS&lt;/b&gt; Contains a reference to every variable which is currently available within the global 
scope of the script. The keys of this array are the names of the global variables.
&lt;li&gt;&lt;b&gt;$_SERVER&lt;/b&gt; Variables set by the web server or otherwise directly related to the execution environment 
of the current script.
&lt;li&gt;&lt;b&gt;$_GET&lt;/b&gt; Variables provided to the script via HTTP GET.
&lt;li&gt;&lt;b&gt;$_POST&lt;/b&gt; Variables provided to the script via HTTP POST.
&lt;li&gt;&lt;b&gt;$_COOKIE&lt;/b&gt; Variables provided to the script via HTTP cookies.
&lt;li&gt;&lt;b&gt;$_FILES&lt;/b&gt; Variables provided to the script via HTTP post file uploads.
&lt;li&gt;&lt;b&gt;$_ENV&lt;/b&gt; Variables provided to the script via the environment.
&lt;li&gt;&lt;b&gt;$_REQUEST&lt;/b&gt; Variables provided to the script via the GET, POST, and COOKIE input mechanisms.
&lt;/ul&gt;
&lt;b&gt;Variable scope&lt;/b&gt;
&lt;ul&gt;
&lt;li&gt;For the most part all PHP variables only have a single scope. See example below:
  &lt;br&gt;
&lt;textarea rows=3 cols=60&gt;
$user = "Black";
require "main.php";&lt;/textarea&gt;
  &lt;br&gt;
  In above example $user is available to main.php also.
&lt;li&gt;
 PHP Variable used inside a function is limited to the local function scope. For example: 
  &lt;br /&gt;&lt;textarea rows=6 cols=60&gt;
$user = "Black";
function print_user()
{
 echo $user; 
 // will not print 'Black' because $user refer to the local scope
}&lt;/textarea&gt;&lt;br /&gt;
  The global keyword is used in this case to refer to variable $user. See Below:
  &lt;br /&gt;&lt;textarea rows=6 cols=60&gt;
$user = "Black";
function print_user()
{
 global $user;
 echo $user; 
 // will print 'Black' as $user now refer to the global variable
}&lt;/textarea&gt;&lt;br /&gt;
&lt;li&gt;A static variable exists only in a local function scope, it retain its value when program 
  execution leaves this scope. see example below: 
  &lt;br /&gt;&lt;textarea rows=6 cols=60&gt;
function Test()
{
  static $a = 0;
  $a++;
  echo $a;
}&lt;/textarea&gt;&lt;br /&gt;
  Everytime Test() is called it increments the value of $a and prints it. First time will print
  1, second time 2 and so on.
&lt;li&gt;Variable variable names takes the name of the variable from other variable. See Below:
  &lt;br /&gt;&lt;textarea rows=5 cols=60&gt;
$user = "White";
$$user = "Black"; 
// this will create variable $White with value Black.
$other_name = ${$user} 
// this is used to access value of variable variable.&lt;/textarea&gt;&lt;br /&gt;

&lt;/ul&gt;
&lt;/div&gt;

&lt;h4&gt;&lt;a name="constants"&gt;PHP Constants&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
define() functin is used to create constants in PHP. Its value cannot be changed during the execution of the script and they are having global scope and accessed anywhere in the script.
See exampe Below:
&lt;br /&gt;&lt;textarea rows=1 cols=60&gt;
define("PIE", "3.14");&lt;/textarea&gt;&lt;br /&gt;
&lt;b&gt;Predefined constants&lt;/b&gt; PHP provides some
special constants which are case-insensitive and are as follows: 
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;__LINE__&lt;/b&gt; current line number of the file.  
&lt;li&gt;&lt;b&gt;__FILE__&lt;/b&gt; full path and filename of the file.  
&lt;li&gt;&lt;b&gt;__FUNCTION__&lt;/b&gt; function name
&lt;li&gt;&lt;b&gt;__CLASS__&lt;/b&gt; class name.
&lt;li&gt;&lt;b&gt;__METHOD__&lt;/b&gt; class method name
&lt;/ul&gt;
&lt;/div&gt;

&lt;h4&gt;&lt;a name="data"&gt;PHP Data Types&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
PHP supports followin Data types&lt;br&gt;
&lt;b&gt;Standard Data Types&lt;/b&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Integer&lt;/b&gt;
  Integers are signed or unsigned whole numbers can be specified in decimal (10-based), hexadecimal 
  (16-based) or octal (8-based). See Examples Below:
  &lt;br /&gt;&lt;textarea rows=4 cols=60&gt;
$a = 1234; # decimal number
$a = -123; # a negative number
$a = 0123; # octal number (83 decimal)
$a = 0x1A; # hexadecimal number (26 decimal)&lt;/textarea&gt;&lt;br /&gt;
 
&lt;li&gt;&lt;b&gt;floats/doubles/real numbers&lt;/b&gt; Floating point numbers can be specified using any of the following: 
  &lt;br /&gt;&lt;textarea rows=3 cols=60&gt;
$f = 1.234; 
$f = 1.2e3; 
$f = 7E-10;&lt;/textarea&gt;&lt;br /&gt;

&lt;li&gt;&lt;b&gt;String&lt;/b&gt; String data type is a collection of characters. backslash (\) is an escape character. 
Following are some string examples 
  &lt;br /&gt;&lt;textarea rows=6 cols=60&gt;
//Single Quoted, only have \' escape character.
$str = 'I\'ll be back';
$str = 'Sun is shining \n'; // will not escape \n.
//Double Quoted, have more special escape sequence
$str = "I'll be back in \"10\" minutes ";
$str = "Sun is shining \n"; // will escape \n.&lt;/textarea&gt;&lt;br /&gt;

&lt;li&gt;&lt;b&gt;Boolean&lt;/b&gt; It can be either TRUE or FALSE and case in-sensitive. See Below
  &lt;br /&gt;&lt;textarea rows=2 cols=60&gt;
$done = TRUE;
$notdone = False;&lt;/textarea&gt;&lt;br /&gt;
 
&lt;li&gt;&lt;b&gt;Object&lt;/b&gt; This is an instance of a class. 
The new statement is used to instantiate the object to a variable. See Below
  &lt;br /&gt;&lt;textarea rows=5 cols=60&gt;
class someClass
{
 ...
}
$obj = new someClass;&lt;/textarea&gt;&lt;br /&gt;

&lt;li&gt;&lt;b&gt;Array&lt;/b&gt; An array in PHP is an ordered map that maps values to the keys. See examples below:
  &lt;br /&gt;&lt;textarea rows=6 cols=60&gt;
$arr = array(1,2,15,18,20); 
// if key is not given key starts from 0.. 
//i.e $arr[0],$arr[1]..

$arr = array("one"=&gt;1,"tow"=&gt;2,"three"=&gt;15); 
// using keys one, two..&lt;/textarea&gt;&lt;br /&gt;
&lt;/ul&gt;

&lt;b&gt;Special Data Types&lt;/b&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Resource&lt;/b&gt; A resource is a special variable, holding a reference to an external resource.
A reference handlers to opened files, database connections, image canvas for example.
 
&lt;li&gt;&lt;b&gt;NULL&lt;/b&gt; An uninitialized variable, represents that a variable has no value
&lt;/ul&gt;
 
&lt;/div&gt;

&lt;h4&gt;&lt;a name="operators"&gt;PHP Operators&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;

&lt;b&gt;Arithmetic Operators&lt;/b&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;=&lt;/b&gt; Assignment,  for example $a = 5; , $a = $b+5;
&lt;li&gt;&lt;b&gt;+&lt;/b&gt; Addition for example $a+$b
&lt;li&gt;&lt;b&gt;-&lt;/b&gt; Subtraction for example $a-$b
&lt;li&gt;&lt;b&gt;/&lt;/b&gt; Division for example $a/$b
&lt;li&gt;&lt;b&gt;*&lt;/b&gt; Multiplication for example $a*$b
&lt;li&gt;&lt;b&gt;%&lt;/b&gt; Modulus for example $a%$b
&lt;/ul&gt;
 
&lt;b&gt;Comparison Operators&lt;/b&gt;
are used to perform tests on their operands and they return true or false based on the value of operands.
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;==&lt;/b&gt; Equal to for example $a == $b
&lt;li&gt;&lt;b&gt;!=&lt;/b&gt; Not Equal to $a != $b
&lt;li&gt;&lt;b&gt;&lt;&gt;&lt;/b&gt; Not Equal to $a &lt;&gt; $b
&lt;li&gt;&lt;b&gt;===&lt;/b&gt; Equal to and of same type for example $a === $b
&lt;li&gt;&lt;b&gt;!==&lt;/b&gt; Not Equal to or they are not of the same type $a !== $b
&lt;li&gt;&lt;b&gt;&gt;&lt;/b&gt; Greater than for example $a &gt; $b
&lt;li&gt;&lt;b&gt;&gt;=&lt;/b&gt; Greater than or equal to for example $a &gt;= $b
&lt;li&gt;&lt;b&gt;&lt;&lt;/b&gt; Less than for example $a &lt; $b
&lt;li&gt;&lt;b&gt;&lt;=&lt;/b&gt; Less than or equal to for example $a &lt;= $b
&lt;/ul&gt;

&lt;b&gt;Bitwise Operators&lt;/b&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;&amp;&lt;/b&gt; And Bits, $x = $a &amp; $b; will set bits in $x which are set in both $a and $b
&lt;li&gt;&lt;b&gt;|&lt;/b&gt; Or Bits, $x = $a | $b; will set bits in $x which set in either $a or $b
&lt;li&gt;&lt;b&gt;^&lt;/b&gt; Xor Bits, $x = $a ^ $b; will set bits in $x which set in $a or $b but not in both
&lt;li&gt;&lt;b&gt;~&lt;/b&gt; Not Bits, $x = ~ $a; Reverse bits of $a i.e. 1 to 0 and 0 to 1
&lt;li&gt;&lt;b&gt;&lt;&lt;&lt;/b&gt; Shift left, $a &lt;&lt; 4; Shifts bits of $a 4 steps to left
&lt;li&gt;&lt;b&gt;&gt;&gt;&lt;/b&gt; Shift right, $a &gt;&gt; 3; Shifts bits of $a 3 steps to right
&lt;/ul&gt;

&lt;b&gt;Logical Operators&lt;/b&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;and, &amp;&amp;&lt;/b&gt; And, ($a&gt;1) &amp;&amp; ($a&lt;5) TRUE if both are true
&lt;li&gt;&lt;b&gt;or, ||&lt;/b&gt; Or, ($a&gt;1) or ($a&lt;5) TRUE if either is true
&lt;li&gt;&lt;b&gt;xor&lt;/b&gt; Xor, ($a&gt;1) xor ($a&lt;5) TRUE if either is true but not both
&lt;li&gt;&lt;b&gt;!&lt;/b&gt; Not, !$a TRUE if $a is not true
&lt;/ul&gt;

&lt;b&gt;Increment/decrement Operators&lt;/b&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;++$a&lt;/b&gt; Increments $a by one, then returns $a
&lt;li&gt;&lt;b&gt;--$a&lt;/b&gt; Decrements $a by one, then returns $a
&lt;li&gt;&lt;b&gt;$a++&lt;/b&gt; Returns $a, then increments $a by one
&lt;li&gt;&lt;b&gt;$a--&lt;/b&gt; Returns $a, then decrements $a by one
&lt;/ul&gt;

&lt;b&gt;Other Operators&lt;/b&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;@&lt;/b&gt; This is an error control operator when prepended to an expression any error messages that might be generated by that expression will be ignored
&lt;li&gt;&lt;b&gt;``&lt;/b&gt; This is an execution operator will execute the contents of the backticks as a shell command for example $a = `ls`; will return the ourput of ls shell command.
&lt;li&gt;&lt;b&gt;.&lt;/b&gt; This is a string operator which returns the concatenation of its right and left strings for example $c = $a."Some String"
&lt;li&gt;&lt;b&gt;.=&lt;/b&gt; This is a string concatenating assignment operator for example $a .= "Some String" will append "Some String" to the right of $a
&lt;/ul&gt;
&lt;/div&gt;

&lt;h4&gt;&lt;a name="control"&gt;PHP Control Structures&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;if&lt;/b&gt; allows for conditional execution of code fragments. see example below
&lt;br&gt;&lt;textarea rows=5 cols=60&gt;
if ($a &gt; $b) 
{
 //will execute code here when $a is greater than $b.
}&lt;/textarea&gt;
&lt;li&gt;&lt;b&gt;else&lt;/b&gt; extends an if statement to execute a statement in case the expression in the if statement 
evaluates to FALSE. see example below
&lt;br&gt;&lt;textarea rows=8 cols=60&gt;
if ($a &gt; $b) 
{
 //will execute code here when $a is greater than $b.
}
else
{
 //will execute code here when $a is NOT greater than $b.
}&lt;/textarea&gt;
&lt;li&gt;&lt;b&gt;elseif / else if&lt;/b&gt; unlike else, as its name suggests, it will execute alternative code only 
if the elseif condition is TRUE. see example below
&lt;br&gt;&lt;textarea rows=12 cols=60&gt;
if ($a &gt; $b) 
{
 //will execute code here when $a is greater than $b.
}
elseif($a == $b))
{
 //will execute code here when $a is Equal to $b.
}
else
{
 //will execute code here when above both are FALSE.
}&lt;/textarea&gt;

&lt;li&gt;&lt;b&gt;switch&lt;/b&gt; is used to compare the same variable with many different values, and execute 
a different code depending on value of variable or expression. see example below
&lt;br&gt;&lt;textarea rows=14 cols=60&gt;
switch ($a) {
case 0:
    //will execute code here when $a is 0.
    break;
case 1:
    //will execute code here when $a is 1.
    break;
case 2:
    //will execute code here when $a is 2.
    break;
default:
    //will execute code here when all cases are failed.
    break;
}&lt;/textarea&gt;
&lt;br&gt;This is equivalent to a series of if..elseif statements and "break" statement is used to terminate the 
execution of code for the given case.
&lt;li&gt;&lt;b&gt;Alternative syntax&lt;/b&gt; for Control Structures is
to change the opening brace to a colon (:) and the closing 
brace to endif;, or endswitch; see example below
&lt;br&gt;&lt;textarea rows=7 cols=60&gt;
if ($a == 5):
    echo "a equals 5";
elseif ($a == 6):
    echo "a equals 6";
else:
    echo "a is neither 5 nor 6";
endif;&lt;/textarea&gt;
&lt;/ul&gt;

&lt;/div&gt;

&lt;h4&gt;&lt;a name="functions"&gt;PHP Functions&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;b&gt;Defining a Function&lt;/b&gt; in PHP can be done using function statement. see below
&lt;br&gt;&lt;textarea rows=8 cols=60&gt;
function min($a, $b) 
{
 if ($a&lt;$b) return $a;
 return $b;
}

$a = 5;
$b = 6;
$m = min($a,$b); // Calling function&lt;/textarea&gt;
&lt;br&gt; A return statement is used to return values from the function
&lt;li&gt;&lt;b&gt;Function with an Optional Argument&lt;/b&gt; can be defined using following
&lt;br&gt;&lt;textarea rows=5 cols=60&gt;
function generate_url($action, $id="") 
{
 $url = "main.php?action=".$action;
 if ($id!="") $url .= "&amp;id=".$id;
 return $url;
}&lt;/textarea&gt;
&lt;br&gt;In above function $id is optional and if given will be appended to the returning url.

&lt;li&gt;&lt;b&gt;Making arguments be passed by reference&lt;/b&gt; allows the function to change its argument 
which is not possbile when it is passed by value. This is done by '&amp;' see below
&lt;br&gt;&lt;textarea rows=7 cols=60&gt;
function add_hello(&amp;$str)
{
 $str = "Hello, ".$str;
}
$str = "White";
add_hello($str);
echo $str;    // will output "Hello, White";&lt;/textarea&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;h4&gt;&lt;a name="coding"&gt;PHP Coding&lt;/a&gt;&lt;/h4&gt;
&lt;div class="topic"&gt;
A code in any programming language is a series of statements. 
A statement can be an assignment, a function call, 
a loop, a conditional statement of even an empty statement which does nothing.
In PHP a statement is terminated with semicolon(;). Multiple statements
can be grouped using the curly braces ({...}). 
// and /*..*/ is used to insert comments in PHP.
See example below 
&lt;br&gt;&lt;textarea rows=17 cols=60&gt;
/*
 This is a comment. This is simple php code.
*/
$a=5; //assingment statement
$str1 = "a is greater than 5";
$str2 = "a is NOT greater than 5";

if($a&gt;5) //Conditional statement
{
 echo $str1;
}
else
{ // start statement group
 echo $str2;
 function1(); //function call
} // end statement group&lt;/textarea&gt;
&lt;br&gt;&lt;br&gt;
&lt;b&gt;Embedding PHP in HTML:&lt;/b&gt;
PHP is especially suited for Web development and can be embedded into HTML. This can be
done by using some special start and end tags. See example below
&lt;br&gt;&lt;textarea rows=19 cols=60&gt;
// ustig tag &lt;?php. . .?&gt; 
[html]
 &lt;?php echo("PHP is embeded using tag &lt;?php. . .?&gt;"); ?&gt;
[/html]

// ustig tag &lt;script language="php"&gt;. . .&lt;/script&gt;
[html]
 &lt;script language="php"&gt;
  echo("PHP is embeded using long tag");
 &lt;/script&gt;
[/html]

// ustig short tag &lt;?. . .?&gt; 
[html]
  &lt;? echo("PHP is embeded using short tag"); ?&gt;
[/html]&lt;/textarea&gt;

&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/727499088252185747-6328117519313003091?l=phpnmysql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpnmysql.blogspot.com/feeds/6328117519313003091/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=727499088252185747&amp;postID=6328117519313003091' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/727499088252185747/posts/default/6328117519313003091'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/727499088252185747/posts/default/6328117519313003091'/><link rel='alternate' type='text/html' href='http://phpnmysql.blogspot.com/2007/04/php-beginners-php-language-elements.html' title='PHP Elements PHP Language Reference PHP Quick Reference'/><author><name>H. P.</name><uri>http://www.blogger.com/profile/08808176886063562208</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-727499088252185747.post-8285958213088139191</id><published>2007-03-03T06:39:00.000-08:00</published><updated>2008-11-22T05:53:06.851-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySql'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP'/><category scheme='http://www.blogger.com/atom/ns#' term='MySql Basics'/><category scheme='http://www.blogger.com/atom/ns#' term='PHP Basics'/><title type='text'>Introduction PHP Introduction PHP MySql Introduction</title><content type='html'>&lt;h4&gt;PHP Intoroduction&lt;/h4&gt;
&lt;p align="justify"&gt;
PHP is widely-used today as a scripting language in dynamic web site development. It is an Open Source scripting language best suited for dynamic web page development and can easily be embedded into HTML. PHP is mainly focused on server-side scripting, so you can do anything, such as collect form data, generate dynamic page content, or send and receive cookies. But PHP can do much more.
&lt;/p&gt;
&lt;p align="justify"&gt;
PHP is a server side language that is executed on the server and client will only know the result of the script without knowing the underlying PHP code. The best thing of PHP is that it is very simple to learn but it offers many advanced features. We can use PHP for simple web page development to a very highly sophisticated erp applications.
&lt;/p&gt;

&lt;h4&gt;PHP MySql Intoroduction&lt;/h4&gt;
&lt;p align="justify"&gt;
One of the biggest advantage of using PHP is how easily it interacts with the underlying database system. Using PHP MySql combination, writing a database-enabled web page is incredibly simple. One of the strongest and most significant feature in PHP is its support for a wide range of databases. It supports Ingres, Oracle, d Base, PostgreSQL, mSQL, MS-SQL, Sybase, MySQL and many other. Although PHP supports these many databases, MySQL an Open Source RDBMS, is commonly used today because it runs easily on Windows and UNIX and for many other reasons. MySQL supports most of the functionality those are in a commercial RDBMS. One major area where MySQL falls short was its lack of support for stored procedures and triggers. However, both of these features are included in the current release 5.0. MySQL database is used to store and organize information on the web and PHP is used to extract and include these information into the web pages.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/727499088252185747-8285958213088139191?l=phpnmysql.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://phpnmysql.blogspot.com/feeds/8285958213088139191/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=727499088252185747&amp;postID=8285958213088139191' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/727499088252185747/posts/default/8285958213088139191'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/727499088252185747/posts/default/8285958213088139191'/><link rel='alternate' type='text/html' href='http://phpnmysql.blogspot.com/2007/03/introduction.html' title='Introduction PHP Introduction PHP MySql Introduction'/><author><name>H. P.</name><uri>http://www.blogger.com/profile/08808176886063562208</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
