Getting Started with PHP

Source: Internet
Author: User

<! DOCTYPE html Public"-//w3c//dtd XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >Echo' Hello world! ' ;</script><?Echo' Hello world! '; ><%Echo' Hello world! '; %><?PHPEcho"Hello world!";//single-line comment    Echo"<p>" ; /*Multi-line comments*/    #shell script Style comments    $boo=true ; if($boo==true)    {        Echo' Variable $boo is true '. <br> " ; }    $str= ' String ' ; Echo"$str" ; Echo' $str '. " <br> " ; $arr=Array(' A1 ', ' A2 ', ' A3 ') ; Echo"Current file path:".__file__." <br> ";//pre-defined constants    $str 1=$str;//assigning values, using their own memory    $str 2= &$str 1  //reference Assignment (equivalent to another name)? ><?PHPfunctionFUN1 ($sum)//Defining Functions    {        return"$sum*$sum= ".$sum*$sum ; }    EchoFUN1 (10). " <br> " ; $con=mysql_connect("localhost", "root", "Newman");//connect to MySQL database    if(!$con)      {           die(' Could not connect: '.Mysql_error()); }/*if (mysql_query ("CREATE Database my_db", $con)) {//CREATE DATABASE echo "DB created"; } else {echo "Error Creating Database:".      Mysql_error (); }*/        mysql_select_db("my_db",$con);//Select a database/*$sql = "CREATE TABLE Persons (personID int not NULL auto_increment, PRIMARY KEY (PersonID), FirstName varchar (LastName), varchar (+), age int) ";*//*mysql_query ("INSERT into Persons (FirstName, LastName, age) VALUES (' Peter ', ' Griffin ', ' 35 ')"); mysql_query ("INSERT into Persons (FirstName, LastName, age) VALUES (' Glenn ', ' quagmire ', '") ");*/        $result=mysql_query("SELECT * from Persons WHERE firstname= ' Peter '"); //$result = mysql_query ("select * from Persons ORDER by age");    mysql_query("UPDATE Persons SET age = ' ' WHERE FirstName = ' Peter ' and LastName = ' Griffin '"); //mysql_query ("DELETE from Persons WHERE lastname= ' Griffin '");     while($row=Mysql_fetch_array($result))      {          Echo $row[' FirstName ']. " " .$row[' LastName ']             . " " .$row[' Age ']; Echo"<br/>"; }    Mysql_close($con);?></body>

For the first time, you need to run the CREATE database and database table in the comment, and comment out the Add record code to the database table to avoid adding it multiple times.

Getting Started with PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.