Php5 and mysql5 web development technology-3 variables, expressions, and constants

Source: Internet
Author: User
Tags constant definition

1. Define, name, and classify scalar variables, array variables, and objects. 2. Print and output the echo statement printf () function example :: printf ("% d bootles of beer on % s", 100, "the wall"); printf ("The % 2 \ $ s liks to % 1 $ s ", "bark", "dog"); sprintf () function instance: $ formatted = fprintf ("% 01.2f", $ var ); 3. display the array and the object print_r (array and variable); var_dump (array \ variable \ object) var_export (array \ variable \ object). By setting parameters, you can return the instance of variables: $ v = var_export ($ a, true); // return the php source code, directly used in the php script Array 4. Data Type shaping, double precision, complex, Boolean array, object, resource (Resou) supported by php Variables Rce) NULL two methods reference string: Double quotation marks and single quotation marks variable type acquisition and setting: gettype ()/settype () arrays and objects are called variables that conform to the Data Type 5. $ var_name = 'php5 '; $ var_name = ''php5 web development details; echo $ php5; 6. Super global variable array $ _ GET [] $ _ POST [] $ _ COOKIE [] $ _ SESSION [] $ _ ENV [] $ _ SERVER [] $ _ FILES [] $ _ REQUEST [] $ _ GLOBALS [] 7. There are many variable operators, only lists types but not specific ones. After the arithmetic value assignment string is connected to the frontend and backend plus or minus references and the referenced value assignment, the variable has the same memory address as the ternary operator to compare other operators of the Boolean operator bit operator: 1. Error suppression @ 2. Execute External commands $ out = · dir c: · print_r ($ out); $ our = shell_exec ("dir"); echo $ out; the results of the two functions are the same. Put the results in an array. The shell_exec () method places the results in a scalar variable. 8. Variable and step-by-step processing isset () unset () empty () is_array () \ is_integer () \ is_numeric () 9. Data Conversion: (array) (bool)/(boolean) (int) (object) (real)/(double)/(fload) (string) Other: (1) intval ($ var): (2) HereDoc allows php to embed large text content, such as an email template or html or text content. $ String = 'hello'; $ output = <the value of \ $ string in mydoc heredoc is $ stringMYDOC echo $ output. The output result is: in HEREDOC, the value of $ string is "hello (3) conversion character \ n, \ t, \, \ $, \'' (4). the value Conversion Function chr ($ var ): returns the corresponding ASCII character based on the value of $ var; ord ($ string) returns the ASCII value of the first character of the string; 10, constant definition and magic constant define ("CONSTANT_NAME ", constant Value) _ LINE _ FILE _ FUNCTION _ CLASS _ METHOD __

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.