Basic Php TutorialsBasic PHP tutorials and for beginners..PHP Switch Statement- May 10, 2005 Php Switch statement is very useful, it works like ifelse statement & reduce the complication of numerous conditions in the script.Syntax :switch (expression)case 1code .. execute code if expression = 1break;case 2code ... execute code if expression = 2break;default:code...execute code if expression not matchedExample :<php$value = 6;switch ($value)case 1:echo "Value 1";break;case 2:echo "Value 2";break;case 3:echo "Value 3";break;default:echo "Value is " . $value . " not matched!";>http://phpstreet.blogspot.com/2007/05/php-switch-statement.html The while Statement- May 9, 2005 The while StatementThe while statement is useful, when you want to loop a code until it's conditions are met.Syntax :while (condition)code ....Example :");echo "Value is ". $val .". condition not met!";$val++;Output of this code is :Value is 0. condition not met!Value is 1. condition not met!Value is 2. condition not met!Value is 3. condition not met!Value is 4. condition not met!Value is 5. condition not met!Value is 6. condition not met!Value is 7. condition not met!Value is 8. condition not.http://phpstreet.blogspot.com/2007/05/while-statement.html The do while Statement- May 8, 2005 The doWhile repeat through the code, until the condition is met.Syntax :docode ...while (condition);Example :";while ($valOutput of this code :Value is 1Value is 2Value is 3http://phpstreet.blogspot.com/2007/05/do-while-statement.html Php For Statement- May 7, 2005 PHP For statement is used when you want to loop the code for number of times,until condition is met.Syntax :for (initialization; condition; increment)code ...Example :<phpfor ($val=1; $val<=3; $val++)echo "This is the text.<br >";>Output of this Php code is :This is the text.This is the text.This is the text.http://phpstreet.blogspot.com/2007/05/php-for-statement.html Php Functions- May 6, 2005 PHP functions are very useful, because once coded, it can be called from anywhere within the script or from outside. Note, code block must start with function word.Example 1 : Shows how to call function within the php Script.<phpfunction MyFirstEchoFunction()echo "Hi this is the function called! <br >";echo "And this is text created by function!";MyFirstEchoFunction()>Another way of calling functions is using include()..Php Include() lets you import any php or text file in your...http://phpstreet.blogspot.com/2007/05/php-functions.html PHP Forms- May 5, 2005 This is the fun part! sooner or later, we all want to collect user data. We can build nifty data collector using HTML and PHP GETPOST .Create a HTML form Something like.. Easier if you do it in HTML editor. and name it "myform.html"<form name="form1" method="post" action="collect.php">Name :<input type="text" name="name"><br>Email :<input type="text" name="email"><br><input type="submit" name="Submit" value="Submit"><formNow Create another file, this...http://phpstreet.blogspot.com/2007/05/html-forms-php-out.html PHP Predefined variables- May 4, 2005 PHP provides a large number of predefined variables to any script which it runs. Many of these variables, From version 4.1.0 onward, PHP provides an additional set of predefined arrays containing variables from the web server (if applicable), the environment, and user input. These new arrays are rather special in that they are automatically global--i.e., automatically available in every scope. For this reason, they are often known as "superglobals".PHP...http://phpstreet.blogspot.com/2007/05/php-predefined-variables.html Php $_GET Variable- May 3, 2005 php $_GET variable is a predefined php variable name, and values are sent by the HTTP GET method. Get method is not so profound, and the amount of data can be sent is max 100 characters, it displays data (including passwords and usernames) in user's browser address bar, Also makes it vulnerable to SQL injections (Kind of My SQL exploitation done by typing characters in address bar) .However it is useful, when you want to point to a particular page to retrive data...<a...http://phpstreet.blogspot.com/2007/05/php-get-variable.html Php $_POST Variable- May 2, 2005 PGP $_POST variable is a predefined php variable name, and values are sent by the HTTP POST method, exactly like $_GET variable, but data sent from a form with $_POST method is invisible to user.Example :"myform.html": <form action="collect.php" method="POST">Name: <input type="text" name="name" >Email: <input type="text" name="email" ><input type="submit" ><form>"collect.php"< phpecho $_POST"name" ."<br >";echo $_POST"email" ;>With POST method you can..http://phpstreet.blogspot.com/2007/05/php-post-variable.html |