PHP Basics Review _ PHP Tutorial

Source: Internet
Author: User
Tags php basics
PHP basic knowledge review. Header (Content-Type: texthtml; charsetUTF-8); $ connmysql_connect (localhost, root,); linked server (non-permanent) if (! $ Conn) {echohr; die (error:. mysql_error ();} el header ("Content-Type: text/html; charset = UTF-8 ");
$ Conn = mysql_connect ('localhost', 'root', ''); // link server (non-permanent)
If (! $ Conn ){
Echo' ';
Die ('Error: '. mysql_error ());
} Else {
Echo' ';
Echo 'linked server: '. $ conn;
}

$ Db = mysql_select_db ('test', $ conn); // select a database
If (! $ Db ){
Echo' ';
Die ('Error: '. mysql_error ());
} Else {
Echo' ';
Echo 'link database: '. $ db;
}

/*
Mysql_query () only returns a resource identifier for SELECT, SHOW, EXPLAIN or DESCRIBE statements. if the query execution is incorrect, FALSE is returned.
For other types of SQL statements, if mysql_query () is executed successfully, TRUE is returned. If an error occurs, FALSE is returned.
If the return value is not FALSE, the query is legal and can be executed by the server. This does not indicate any affected or returned number of rows. It is very likely that a query is successfully executed but does not affect or no rows are returned.
*/
$ SQL = "SELECT * FROM user ";
$ Result = mysql_query ($ SQL, $ conn); // executes a MySQL Query. this function automatically reads and caches the record set. To run a non-cache query, use mysql_unbuffered_query ().
Echo' ';
Echo 'query result set: '. $ result; // The Resource identifier returned.
// Echo' ';
// Print_r (mysql_fetch_array ($ result, MYSQL_ASSOC); // The function retrieves a row from the result set as the associated array
// Echo' ';
// Print_r (mysql_fetch_array ($ result, MYSQL_NUM); // The function retrieves a row from the result set as a numeric array
// Echo' ';
// Print_r (mysql_fetch_array ($ result); // The function retrieves a row from the result set as the associated array and number array. the mysql_fetch_row () function retrieves a row from the result set as the number array.

/*
The mysql_fetch_array () function retrieves a row from the result set as an associated array, or an array of numbers, or both.
Returns the array generated based on the rows obtained from the result set. If no more rows exist, false is returned.
*/
Echo' ';
Echo'









';While ($ row = mysql_fetch_array ($ result )){Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";Echo" ";}Echo'
". $ Row ['firstname']."". $ Row ['lastname']."". $ Row ['age']."". $ Row ['Hometown ']."". $ Row ['job']."
';

Echo' ';
Echo 'close a non-persistent MySQL connection: '. mysql_close ();

$ Name = array ('Fruits '=> array ('Orange', 'banana ', 'apple '),
'Veggi' => array ('carrot', 'colard', 'pea '));;
Echo' ';
Print_r ($ name ['Fruits '] [1]);
Echo' ';
Echo count ($ name); // calculates the number of units in the array or the number of attributes in the object.

Echo' ';
/*
The symbol "->" indicates the function and member variable of the call class.
*/
Class className {
Function funName (){
Echo "dggdgdgd ";
}
}
$ ClassOne = new className ();
$ ClassOne-> funName ();

Echo' ';
$ I = 0;
Do {
$ I ++;
Echo "The number is". $ I ."
";
}
While ($ I <5 );

Http://www.bkjia.com/PHPjc/325737.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/325737.htmlTechArticleheader ("Content-Type: text/html; charset = UTF-8"); $ conn = mysql_connect ('localhost', 'root ',''); // link the server (non-permanent) if (! $ Conn) {echo 'HR/'; die ('Error:'. mysql_error ();} el...

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.