PHP learning Notes (1)

Source: Internet
Author: User
PHP learning Notes (1) & nbsp; PHP script with & lt ;? Php starts? & Gt; end. & Lt ;?? & Gt; to start and end the script block. To ensure compatibility, try to use the standard format. PHP usually contains HTML tags, like HTML files, and some ph php study notes (1)
 


PHP script End. You can use To start and end the script block. To ensure compatibility, try to use the standard format. PHP usually contains HTML tags, such as HTML files and some PHP script code. Below is a simple PHP code,

   
 


There are two basic commands for outputting text through PHP, echo and print.

All variables in PHP start with the $ symbol.

The correct method for setting variables is:

$ Var_name = value;

PHP is a loose language. in PHP, you do not need to declare the variable before setting it.

PHP automatically converts a variable to a correct data type based on the method in which the variable is set.

In PHP, variables are automatically declared during use.

In PHP, there is only one string operator.

The concatenation operator (.) is used to connect two strings.

For example:

$txt1="Hello World";
$txt2="nihao";
echo $txt1 . " " . $txt2;

?>

Above code output

Hello World nihao
 
 
The strpos () function is used to retrieve a string or a character within a string.
If a match is found in the string, the function returns the first matched position. If no matching is found, FALSE is returned.
For example:
 

 

 


The returned value is 6 (starting from 0)


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.