PHP Learning Notes (i) Simple learn php,php Learn notes Learn _php Tutorials

Source: Internet
Author: User
Tags php website

PHP Learning Notes (a) easy to learn php,php learn notes


Target planning:

With the first lesson, we can learn about the PHP environment.

1. Understanding of the environment:

2. Access method:

3. Modify the code and view it.

4. Use of variables

5. Code indentation to have a hierarchical relationship, and the best between the code to keep blank lines

6. Variable Name:

7. Output of the variable:

8. Three ways to variable:

1. Understanding of the environment:

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

Installation tutorial is very simple, you can Baidu a bit

Post-installation directory structure:

2. Access method:

directly in Browser input: localhost can be accessed

3. Modify the code and view it.

We can modify the above directory www index.php

PHP Output HTML code:

<?phpecho "", Echo "Hello World"; echo "/html";? >

Suggested wording

<?php echo "Hello World";? >

4. Use of variables

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

5. Code indentation to have a hierarchical relationship, and the best between the code to keep blank lines

6. Variable Name:

6.1. Try not to use Chinese

6.2. Try not to start with numbers

6.3. Try not to use meaningless letters

6.4. Variable names are case-sensitive, function names are case-insensitive, class names are not case-sensitive, and variable names and functions are all lowercase.

6.5. Definition of variable must be added $

7. Output of the variable:

Echo $name;

8. Three ways to variable:

Echo ($name); Output variables

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

Print_r ($name);//output array

Example

<?php  $arr =array ("Hu June", "base", "eldest brother"), Print_r ($arr); Var_dump ($arr);  >

Shown below

Through the above display, we can see that the display is very ugly, and do not have to read, so the format of the output scheme:

<?php $arr =array ("Hu June", "Lei Cheng", "eldest brother"); echo "
"; Print_r ($arr); echo "
"; ? >

The results appear as follows:

Small knowledge:

Utf-8 encoding, one Chinese text is 3 characters

GBK encoding, a Chinese is 2 characters


How to make a simple PHP website

You try to use the template bar, all the interface design is for a static web page, this static Web page all you need to use the PHP variables (or other special format you specify) to represent, design layout is the time for such static page operation.

And the site does not directly display the page, all the content of the page has PHP program from the database, the page template inside the variable to replace the output.

For example, your homepage template can be named index.htm, the actual use of index.php to display the first page, PHP process is this:
Link databases, get all kinds of data into variables
$news = ' For example news content ';
Get template
$html =file_get_content (' index.htm ');
Replace a variable in a template
$html =str_replace ('--news--', $news, $html);
Output template
Echo $html;
?>

PHP Learning, PHP connection to the local database a simple message board work can, posted code why not submitted to the database

Your conn.php should be a connection library file for the MySQL database. With this file you can connect to the database, right? But then why Echo $sql, you should mysql_query ah. $result =mysql_query ($sql, $conn) or Die (Mysql_error ());

http://www.bkjia.com/PHPjc/857735.html www.bkjia.com true http://www.bkjia.com/PHPjc/857735.html techarticle PHP Learning Notes (i) simple understanding of php,php learning Notes understanding goal planning: Through the first lesson, we can understand the PHP environment. 1. Environmental awareness: 2. Access method: 3. Modify the code and check ...

  • 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.