PHP learning Notes (1) simple understanding of PHP, php learning notes learn more _ PHP Tutorial

Source: Internet
Author: User
PHP learning Notes (1) brief understanding of PHP and php learning notes. PHP learning Notes (1) brief understanding of PHP, php learning notes objective planning: through the first lesson, we can understand the php environment. 1. environment Awareness: 2. access Method: 3. modify the code and check PHP learning Notes (1) brief introduction to PHP and php learning Notes

Target planning:

Through the first lesson, we can understand the php environment.

1. environment awareness:

2. access method:

3. modify and view the code.

4. use of variables

5. code indentation must have a hierarchical relationship, and it is best to keep blank lines between codes.

6. variable naming:

7. output of variables:

8. three methods of variables:

1. environment awareness:

Software: http://www.bkjia.com/softs/24445.html

The installation tutorial is very simple. you can click here on your own

Directory structure after installation:

2. access method:

Enter localhost in the browser to access

3. modify and view the code.

We can modify index. php in the www directory above.

Php output html code:

<?phpecho "";echo "Hello world";echo "/html";?>

Recommended syntax

 <?php echo "hello world";?>

4. use of variables

<?php $name="junzaivip";  echo "{$name} is good"; ?>

5. code indentation must have a hierarchical relationship, and it is best to keep blank lines between codes.

6. variable naming:

. Try not to use Chinese characters

. Try not to start with a number

. Try not to use meaningless letters

. Variable names are case-sensitive. function names are case-insensitive and class names cannot be case-sensitive.

6. 5. the variable definition must be added with $

7. output of variables:

echo $name;

8. three methods of variables:

Echo ($ name); // output variable

Var_dump ($ name); // output array, and print type and length

Print_r ($ name); // output array

Example:

<? Php $ arr = array ("Hu Jun", "Lei Cheng", "eldest brother"); print_r ($ arr); var_dump ($ arr);?>

Shown below

Through the above display, we can see that the display is very unattractive and does not need to be read, so the formatting output scheme is as follows:

<? Php $ arr = array ("Hu Jun", "Lei Cheng", "eldest brother"); echo"
"; print_r($arr); echo "
";?>

The result is as follows:

Tips:

Utf-8 encoding, a Chinese character is 3 characters

Gbk encoding, a Chinese character is 2 characters


How to make a simple PHP website

Try using the template. all the interface designs are for a static webpage, all the content you need in this static webpage is represented by PHP variables (or other special formats you have defined). during the design layout, such static webpages are operated.

The website does not directly display the webpage. all content on the webpage is obtained by The PHP program from the database, and the variables in the webpage template are replaced and output.

For example, if your first page template can be named index.htm, you can use index. php to display the homepage. The PHP process is as follows:
// Link to the database to obtain various types of data to the variable
$ News = 'news content ';
// Obtain the template
Export html#file_get_content('index.htm ');
// Replace the variables in the template
$ Html = str_replace ('-- news --', $ news, $ html );
// Output Template
Echo $ html;
?>

Php learning: php can connect to the local database with a simple message board. Why can't I submit the code to the database?

Your conn. php should be a mysql database connection file. with this file, you can connect to the database, right? But why echo $ SQL later? you should choose mysql_query. $ result = mysql_query ($ SQL, $ conn) or die (mysql_error ());

Objective (1) a brief understanding of PHP and php learning notes to learn about objective planning: through the first lesson, we can understand the php environment. 1. environment Awareness: 2. access Method: 3. modify code and check...

Related Article

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.