PHP: Personalization syntax in relation to c#,php

Source: Internet
Author: User
Tags constant definition
Background

Today I'm familiar with the basic syntax structure of PHP, including variables, types, constants, operators, strings, scopes, and functions, and this article lists some of the structures I need to strengthen memory (unlike C #).

Some of the individual structures

foreach structure

1 
 
   1, "B" =>2); 3  4 foreach ($array as $value) {5     echo "Value$value
"; 6} 7 8 foreach ($array as $key = + $value) {9 echo "$key + $value
"; Ten}11?>

1 value12 value23 a=>14 b=>2

Global and Static scopes

Variables declared outside the function are global scopes, and the $global within the function $var equivalent to $var = $Globals ["var"]. Variables in the static scope are initialized when the function is first called, the function is not cleaned up, and subsequent function calls are no longer initialized.

1 
 
   ";}13 scope_test (); Scope_test ();?>

1//output Content 2 1, 13 2, 2

Variables of variable

1 
 
   "; 6 echo $Tom."
"; 7?>

1 I am tom2 I am Tom

Constant definition

1 
 
   "; 5?>

1//Output Content 2 3 happiness

String insertion

1 
 
   "; 6?>

1 I am tom,i am tom,i am Tom

Heredoc

1 
 
  

1//Output Content 2 3 De Guangwei

Scope of the function level

1 
 
  

1//Output Content 2 3 11

function returns multiple results

1 
 
  

1//Input Content 2 3 (1, 2)

Note

There is one more question I do not understand, I have to check the information tomorrow, the question is: How is the memory of PHP allocated and managed?

  • 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.