PHP notes - Java programmers understand PHP programs, phpjava programmers understand_PHP tutorial

WBOY
Release: 2016-07-13 09:47:12
Original
988 people have browsed it

PHP Notes - Java programmers understand PHP programs, phpjava programmers understand


1. php is a A server-side scripting language, a loosely typed language.

2.  ?> >  

Script style >

Short style <% >ASPStyle

ends with ;; 3. 

Note:

a) 

// b) 

# c) 

/* */

4. Variables are containers for storing data and are case-sensitive. When the variable is very long, use the delimiter <<<. $k=<<

str;

I think PHP

is a loosely typed language, so there is no specific type when variables are declared. Type keyword.

uniformly start with

$

Variable name

1. must be letters or _begins

2. can only contain alphanumeric characters and underscores 3.

Case sensitive

5. 

Variables can be in

PHP is declared anywhere in the script.

6. Quoted/ Script used - scope

a) local(local )

b) global(global )

c) static(static )

Variables declared outside the function have global scope and can only be outside the function for a visit.

Variables declared inside a function have local scope and can only be used within the function access.

Function internal callglobalVariables need to be used internally global keywords are declared; ②$GLOBAL[index] All global variables are stored in , which can be obtained through the super global variable $GLOBAL[index].

7. $GLOBAL[index]This array is accessible within the function and can be used to directly update global variables.

8. Usually, when the function completes execution, all variables are deleted. If you do not need to delete it, you need to use static

when declaring it for the first time.

9. Constant None$ , cannot be changed in script. Pass define("The name of the constant","The value of the constant”,”Whether the constant name is case-sensitive”);true(Same case)Insensitive, falseSensitive. To define constants in a class, use the const keyword.

A constant that changes depending on where it is used becomes a magic constant.

1) __FILE__ Current folder

2) __LINE__ Current line number

3) __FUNCTION__ Current function name

4) __CLASS__ Current class name

5) __METHOD__ The method name of the current object

10. Print: echo  can output more than one string.

print  can only output a string and always returns 1.

11. strlen();Retrieve the specified characters or text within the stringstrpos(); String concatenation uses ".", .” must be followed by a space. 12.

Super global variable: a) 

$GLOBALS  refers to all variables in the global scope. b) 

$_SERVER Saves information about headers, paths and script locations. c) 

$_REQUEST  is used to collect HTML form submission data. d) 

$_POST               🎜>Widely used to collect submissionsmethod=”post”The form data after the HTML form is also commonly used to pass variables. e) 

$_GET              🎜> is used to collect submissionsHTML form (method="get") can also collect form data after URL< Data sent in 🎜>. f) 

$_FILES

🎜>Upload files from client computer to remote server. g)                                                           Get the server-side environment parameters.

(variables_order=EPGCS) <<> H) $ _ cookie is used to retrieve the value of

cookie. i)                                            is used to store information about a user session, or to change the settings of a user session.

13. The statement will get all the text that exists in the specified file /Code / tag and copy it to the file using the include/require statement. a) 

require(static Loading ), when an error occurs, a fatal error will be generated and the script will stop. b) 

include(dynamic Load ). When an error occurs, only a warning will be generated and the script will continue to execute. c) 

require_once/include_once Contain the same page only once. 14.

Array processing: $Array name['Key name'] to initialize the array; you can also use Array() Function to create an array. count()Returns the length of the array.

Array traversal: foreach

loop, use count()Get the length of the array and then use for;list()Language structure loop, only used for default numeric index ;each() returns key-value pairs. while(list($key,$value)=each($array)){

}

foreach($array as $key => $value){

}

15.

PHPMedium Objects are declared using the class keywords. Class attributes also have scopes. If you do not specify a scope, you can use var is modified. The difference between member methods and functions is that they can be modified with keywords. Constructor__contract,Destructor__destruct 16.

        Scope operator, can be used in Call constants, variables and methods in a class without instantiation; "=>"  

Array member access symbol; "->"  

Object member access symbol;

"=&" Quote (alias);

"="Assignment.

17. $Variable name = new Class name([Parameters]);                             🎜> instantiation; $

Variable name->Member attribute = value;                //Assign a value to the attribute; $

Variable name->Member attributes;                                        >Get attribute value; $Variable name->

Member methods;                                        >How to use; 18. mysql: General Use conn.php

to encapsulate it, then use requireGo to the required page. 1) $conn = mysql_pconnect("localhost","root" ,"") or die(mysql_error());

2)

 mysql_select_db(“ Database name”,$conn);//

Connect to the specified database. 3) mysql_query("set names utf8");

4)

 $sql = “”;

5)

 $resultSet = mysql_query($sql) or die (“Invalid query : ".mysql_error);//Returnsql

statement result set; 6) while($v = mysql_fetch_array($resultSet)){

7)

   echo "

Field name: ".$v['title'];

8) }

9) mysql_free_result($resultSet);//Close the result set;

10) mysql_close($conn);//Close connection

Copy to Google TranslateTranslation result

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1027448.htmlTechArticlePHP notes - java programmers understand PHP programs, phpjava programmers understand 1. php is a server Terminal scripting language, loosely typed language. 2. ?php ? xml style script language=php/sc...

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template