PHP Learning Notes (i)

Source: Internet
Author: User
PHP Learning Notes (i)


PHP script to end. On a server that supports shorthand, you can use it to start and end script blocks. For compatibility, try to use the standard form. PHP usually contains HTML tags, like HTML files, as well as some PHP script code. Here is a simple PHP code,

   
 
  


There are two basic instructions for outputting text via PHP, Echo and print.

All variables in PHP start with the $ symbol.

The correct way to set a variable is:

$var _name = value;

PHP is a loosely typed language, and in PHP it is not necessary to declare a variable before setting it.

Depending on how the variable is set, PHP automatically converts the variable to the correct data type.

In PHP, variables are automatically declared when they are used.

In PHP, there is only one string operator.

The collocated operator (.) Used to connect two strings together.

Such as:

$txt 1= "Hello World";
$txt 2= "Nihao";
echo $txt 1. " " . $txt 2;

?>

The 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 matching position. If no match is found, FALSE is returned.
Such as:

 
  


The return 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.