Home  >  Article  >  Backend Development  >  PHP study notes (1) Simple understanding of PHP, understanding of php study notes_PHP tutorial

PHP study notes (1) Simple understanding of PHP, understanding of php study notes_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:21:23721browse

PHP study notes (1) Simple understanding of PHP, php study notes

Goal Planning:

Through the first lesson, we can understand 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 should be hierarchical, and it is best to keep blank lines between codes

6. Variable naming:

7. Output of variables:

8. Three methods of variables:

1. Understanding of the environment:

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

The installation tutorial is very simple, you can search it on Baidu yourself

Directory structure after installation:

2.Access method:

Directly enter: localhost in the browser to access

3. Modify the code and view it.

We can modify index.php in the above directory www

php output html code:

<&#63;php
echo "<html>";
echo "Hello world";
echo "/html";

&#63;>

Suggested writing methods

<html> <&#63;php echo "hello world";&#63;></html>

4. Use of variables

<&#63;php
 $name="junzaivip";
 
 echo "{$name} is good";
 &#63;>

5. Code indentation should be hierarchical, and it is best to keep blank lines between codes

6. Variable naming:

6.1. Try not to use Chinese

6.2. Try not to start with a number

6.3. Try not to use meaningless letters

6.4. Variable names are case-sensitive, function names are not case-sensitive, and class names are not case-sensitive either. Simply put variable names and functions in lowercase.

6.5. Definition of variables The definition must be added with $

7. Output of variables:

echo $name;

8. Three methods of variables:

echo($name); //Output variable

var_dump($name);//Output the array and print the type and length

print_r($name);//output array

example:

<&#63;php
  $arr=array("胡军","垒成","大哥");
 print_r($arr);
 var_dump($arr);
 
 &#63;>

Displayed as follows

Through the above display, we can see that the display is very ugly and does not require reading, so the formatted output solution is:

<&#63;php
 $arr=array("胡军","垒成","大哥");
 echo "<pre class="brush:php;toolbar:false">";
 print_r($arr);
 echo "
"; ?>

The results are displayed as follows:

Tips:

When encoding in Utf-8, a Chinese character is 3 characters

When gbk is encoded, one Chinese character is 2 characters

How to make a simple PHP website

Try using templates. All interface designs are for a static web page. All the content you need in this static web page is represented by PHP variables (or other special formats specified by you). Design When laying out, such static web pages are operated.

The website does not directly display the web page to the outside. All the content of the web page is obtained from the database by the PHP program, and the variables in the web page template are replaced and output.

For example, your homepage template can be named index.htm, and index.php is actually used to display the homepage. The PHP process is as follows:
bf021d16dda100f2ec8759e610233558

Learn php, a simple message board function can be used to connect php to a local database, why the posted code cannot be submitted to the database

Your conn.php should be a connection library file for mysql database. With this file, you can connect to the database, right? But then why do you need to echo $sql? You should use mysql_query. $result=mysql_query( $sql,$conn)or die(mysql_error());

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/857735.htmlTechArticlePHP study notes (1) Briefly understand PHP, php study notes to understand goal planning: Through the first lesson, we Can understand the php environment. 1. Understanding of the environment: 2. Access method: 3. Modify the code and check...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn