Home > Backend Development > PHP Tutorial > PHP Lesson 1: Briefly understand PHP_PHP Tutorial

PHP Lesson 1: Briefly understand PHP_PHP Tutorial

WBOY
Release: 2016-07-13 10:21:22
Original
871 people have browsed it

PHP Lesson 1: Briefly understand PHP


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://download.csdn.net/detail/junzaivip/7697331

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

Directory structure after installation:



喎?http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcD4KPHA+PC9wPgo8cD4yLrfDzsq3vbeoOjwvcD4KPHA+1rG909Ta5K/AwMb3yuTI6zpsb2NhbGhvc3QgvLS/ybfDzso8L3A+CjxwPjwvcD4KPHA+My7Q3rjEtPrC67ywsum/tC Suggested writing methods

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

?>
Copy after login


Copy after login
<span style="font-family: Arial, Helvetica, sans-serif;"><html></span><span style="font-family: Arial, Helvetica, sans-serif;"> <?php echo "hello world";?></span><span style="font-family: Arial, Helvetica, sans-serif;"></html></span>
Copy after login

4. Use of variables

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

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:


<?php
    $arr=array("胡军","垒成","大哥");
	print_r($arr);
	var_dump($arr);
	
	?>
Copy after login

Displayed as follows


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


"; ?>
<?php
    $arr=array("胡军","垒成","大哥");
	echo "<pre class="code">";
	print_r($arr);
	echo "
Copy after login
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



http://www.bkjia.com/PHPjc/859803.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/859803.htmlTechArticlePHP Lesson 1: A brief understanding of PHP Goal planning: Through the first lesson, we can understand the PHP environment. 1. Understanding of the environment: 2. Access methods: 3. Modify and view the code. 4. Use of variables 5. Code indentation...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template