PHP Beginner Sharing-Data type ____php

Source: Internet
Author: User
String, integer, floating-point number, logic, array, object, NULL.
1, the demarcation sign PHP demarcation symbol to determine the start and end of the PHP script, four different styles to embed PHP code in the HTML code ① standard: <?php? >②: >③js and Vbs:<script Language= ' php ' ></script>④asp:<%%> 2, marker: consists of a character, a number, an underscore, and the first letter must be a character or underscore. The variable begins with $3, is case-sensitive, the statement ends with a semicolon 4, comments:/**///# 6, data type (weakly typed language, variable not given type) Integer,double,string,array,object (object type), Boolean, Resource (Resource), NULL, Boolean (GetType () get data type) 7, the definition of a string: double quotes or single quotes. Difference: Both the variable in double quotes and the escape character are parsed. 8, array initialization array definition: $arr = array (); Assignment: ① $arr [0]= ' str '; $arr [1]=2② $arr []= ' Dong '; $arr []=27; Hash Table Form Array initialization: ① $arr [' name ']= ' Dong ' ② $arr =array (' name ' => ' Dong ');       9. The object class class name {public $ property name;        Public Function function name () {$ variable name; Example: <?php class dong{public $name = ' dong ';
    Public  function get_name ()     {           echo ' dong '; &nbsp ;  } $dong = new Dong (); $dong->get_name (); 10, variables do not need to be defined can be used, the variables defined outside the function is a global variable, within the function defined and used variables are local variables, within the function can not access variables outside the function, in order to access must be within the function, to copy a global variable: global variable name. The variable is the global variable 11, the variable gets the small details: Static variables are decorated with static. For global variables, as long as they are defined, they are stored in the form of a key-value pair into the &global array, and if we want to use it, we can simply fetch the ¥global[$ global variable name] define (' CONTROLLER ',  ' home ');  Define a constant PHP can also pass external variables, there are four forms: $_get form variable submitted to script via HTTP GET method $_post: Form variable submitted to script via HTTP POST method $_file: Uploading a variable submitted to a script via an HTTP POST file $_cookie: A variable submitted to a script via the HTTP cookie method
<?php/** *php Preliminary study * I am a Java-born, learn a lot of things reference to Java * Everyone forgive * data type: String, integer, floating-point number, logic, array, object, NULL.
		*/function firstphp ()//create functions {$str = ' dong ';
		$str _ = "You Are ' dong '";
		String declarations can be used "" or "", can be nested with each other, the difference between a single quotation mark if a variable can not resolve, directly in accordance with the string processing, double quotation marks may be, two, single quotation mark.
		Echo $str;
		Echo ' <br/> ';
		Echo $str _;
		Echo ' <br/> '; $p _array = Array (' Dong ', ', ', ' man ');//does not contain key $p _array_ = Array (' name ' => ' Dong ',27=>27,true=> ' man ');
		that contains key, it can also partially contain key.
		Var_dump ($p _array);//print array echo ' <br/> ';
		Var_dump ($p _array_);
		Echo ' <br/> ';
		Var_dump ($p _array_);
		Echo ' <br/> ';
		Var_dump ($p _array[0]);//using array echo ' <br/> '; Var_dump (' Key array:name--'. $p _array_[' name ']. ', age--'. $p _array_[27]. ', sex--'. $p _array_[true]);//use array $p _array_[
		0] Error notice:undefined offset: note. Is the echo ' <br/> ' in the connection string;
		$p _boolean = false;//logic var_dump ($p _boolean);
		Echo ' <br/> ';
		$p _int = -1;//Integer (positive number of negative numbers) Var_dump ($p _int);
		Echo ' <br/> '; $p _double = 19.89;//floating-point number VAR_dump ($p _double);
		Echo ' <br/> ';
		$p _null = Null;//null var_dump ($p _null);
		Echo ' <br/> ';
		The difference between/** *echo and Var_dump is that the print output *var_dump will print the value and type//object usage $firstPhp = new fisrtphp ();
		Var_dump ($FIRSTPHP);
		Echo ' <br/> ';
		Echo (' shuxing:--'. $firstPhp->dong);

		Echo ' <br/> ';
		$SECONDPHP = new secondphp (' name ');
		Echo ' <br/> ';
		Var_dump ($SECONDPHP);

	Echo ' <br/> ';  firstphp ()///Use function//the following is the result of the operation:/** "Dong" You Are ' Dong ' array (3) {[0]=> string (4) "Dong" [1]=> string (2) 
			' [2]=> string (3) "Man"} Array (3) {[' Name ']=> string (4) "Dong" [27]=> int () [1]=> string (3) "Man"} Array (3) {[' Name ']=> string (4) ' Dong ' [27]=> int () [1]=> string (3) ' Man '} string (4) ' Dong ' string (3 7) "Key Array:name--dong,age--27,sex--man" bool (false) int ( -1) float (19.89) NULL construct---dongcon ob Ject (fisrtphp) #1 (1) {["Dong"]=> string (7) "Myfirst"} Shuxing:--myfirst SEcond construct Object (secondphp) #2 (1) {[SP]=> string (4) ' name '}///object class fisrtphp{public $dong
		= ''; function __construct () {//parent::__construct ()//calling the constructor method of the parent class:: A call to a static method $this->dong = ' myfirst ';//constructor to assign a value to a property Ech
			O ' <br/> '; print ' Construct---'. '
			Dongcon ';
		Echo ' <br/> ';

		}//php5 constructor} class secondphp{public $sp = ';
			function secondphp ($SECONDPHP) {//constructor: php4 Echo ' <br/> ' when the function has the same name as the class;
			Echo ' second construct '; $this->sp = $secondPhp;//constructor assigns value to property}?>


I'm crazy about the dream. In case of realization of what to do.

Dong's personal blog

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.