Home > Backend Development > PHP Tutorial > First introduction to PHP - basic grammar php7 grammar 1200 practical examples of php development sublime php grammar check

First introduction to PHP - basic grammar php7 grammar 1200 practical examples of php development sublime php grammar check

WBOY
Release: 2016-07-29 08:54:25
Original
1358 people have browsed it

I have been preparing to learn PHP, but something happened some time ago and I was delayed for a while. Now hurry up and catch up!

 This series is just about some of my views on PHP, it is not a tutorial. In addition, I am a novice, I just write essays, please give me a pat. I have studied c, java, python, and have been exposed to some HTML. It would be great if friends who have similar experience to me and want to get into PHP can provide you with some ideas.

 In my opinion, PHP has a strong HTML style, and it is indeed born for web programming. One of the biggest features is the way variables are used. In languages ​​​​such as C and Python, a variable is directly called by writing its name in a few characters, such as the classic for (i=0;i<50;i++). However, PHP is closer to HTML in the way it handles variables. Directly written characters will be considered strings. If you want to use variables, you need to start with $: for($i=0;$i<50;$ i++) This makes me very uncomfortable, and I think it will be troublesome to write like this, but after seeing the processing of strings, I found that this has such benefits:

 String splicing in PHP can be done like Python using ",", For example:

$a='Bob';
  echo "Hello ",$a;

The result is as shown below:

php,php语法教程,php语法手册,php教程,php 语法检查,零基础学php,php7 语法,php开发实战1200例,sublime php 语法检

 But The more orthodox way of writing PHP is to use "." for splicing, such as:

$a='Bob';
 echo "Hello ".$a;

The result is the same:

php,php语法教程,php语法手册,php教程,php 语法检查,零基础学php,php7 语法,php开发实战1200例,sublime php 语法检

Here comes the most amazing thing, PHP has an HTML-style usage, which is to directly quote variables in the string:

$a='Bob' ;
  echo "Hello $a";

Still the same result:

This It is the unique style of PHP. php,php语法教程,php语法手册,php教程,php 语法检查,零基础学php,php7 语法,php开发实战1200例,sublime php 语法检 Another feature is the array in PHP. PHP array. In my opinion, PHP's array is a combination of python's list and dictionary. For the data stored, it does not need to declare the type like C arrays. Both integers and strings can be mixed and stored in the same array to "coexist peacefully"; at the same time, it does not only support the use of traditional arrays compiled from 0. The serial number indexing method can be indexed using strings, which is very similar to Python's dictionary. All in all, it's a very strange thing, but it's very convenient if you think about it carefully. $arr = array(

0

=>50,'g'=>'ggg', 1=>

'www'

,'h'=>'hhh');


As shown above, arr is an array with four elements, number 0 is the integer 50; the next element is the string ggg, using the character " g" index; the third element is the string www of element No. 1; the fourth element is the string hhh, indexed using the character "h".

Next, use the array_push function to append a character to the end of the array String element www

$arr = array(0 =>50,'g'=>'ggg',1=>  array_push($arr,'www');
 print_r($arr);

php,php语法教程,php语法手册,php教程,php 语法检查,零基础学php,php7 语法,php开发实战1200例,sublime php 语法检 As shown in the picture above, although the added element is the fifth element, it still continues to be sorted and used. Index No. 2.

This is my feeling about the basic syntax of PHP

The above introduces the basic syntax of PHP, including PHP and syntax. I hope it will be helpful to friends who are interested in PHP tutorials.

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