PHP Learning (i)

Source: Internet
Author: User

Variables in PHP:

1. Define: $ symbol to define the variable

2. Description:

(1) PHP weak language, when defining variables without declaring the type, but does not mean that PHP does not have a data type

(2) Variable names are case-sensitive and can only be numbers, letters, or underscores

(3) The variable defaults to the value assignment, which means that two variables are completely independent after the assignment

$a = "string"; $b $a and pass the value over , and there's noeffect between $a and $b .

(4) PHP also provides another way to assign a value----a reference assignment, when you pass an address

<? PHP $foo  =  ' Bob ';               // Assign ' Bob ' to $foo $bar  $foo ;               // by $bar reference $foo $bar  =  "My name is  $bar ";   // Modifying $bar variables Echo  $bar  ; Echo  $foo ;                  // the value of the $foo is also modified ?>

(5) Globle $a; Used to define global variables, which are used in the body of the function (the function body does not call global variables by default) in PHP string:

1. Definition: Double quotation marks ("") and single quotation marks (') to define a string

"String":

(1) PHP will parse some special characters (escape characters)

(2) Variables in string form will also be parsed

$str = 1; Echo "This is {$str} a string";

Results:

This is a string of 1

' String ':

Just a simple string with no corresponding parsing capability

2. Common methods

String length: strlen (String);

Comparison string: strcmp (string1,string2)----Case-sensitive, returns 0 (same) and 1 (not the same); STRCASECMP (STRING1,STRING2);----case insensitive, returns 0 (same) and 1 (not the same)

Convert Case: Strtolower (String),----to lowercase, strtoupper (string),----to uppercase;

PHP Learning (i)

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.