Table of Contents
PHP Notes - Java programmers understand PHP programs, phpjava programmers understand
Home Backend Development PHP Tutorial PHP notes - Java programmers understand PHP programs, phpjava programmers understand_PHP tutorial

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

Jul 13, 2016 am 09:47 AM
java php program programmer notes

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

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1671
14
PHP Tutorial
1276
29
C# Tutorial
1256
24
What happens if session_start() is called multiple times? What happens if session_start() is called multiple times? Apr 25, 2025 am 12:06 AM

Multiple calls to session_start() will result in warning messages and possible data overwrites. 1) PHP will issue a warning, prompting that the session has been started. 2) It may cause unexpected overwriting of session data. 3) Use session_status() to check the session status to avoid repeated calls.

Composer: Aiding PHP Development Through AI Composer: Aiding PHP Development Through AI Apr 29, 2025 am 12:27 AM

AI can help optimize the use of Composer. Specific methods include: 1. Dependency management optimization: AI analyzes dependencies, recommends the best version combination, and reduces conflicts. 2. Automated code generation: AI generates composer.json files that conform to best practices. 3. Improve code quality: AI detects potential problems, provides optimization suggestions, and improves code quality. These methods are implemented through machine learning and natural language processing technologies to help developers improve efficiency and code quality.

What is the significance of the session_start() function? What is the significance of the session_start() function? May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

What does 'platform independence' mean in the context of Java? What does 'platform independence' mean in the context of Java? Apr 23, 2025 am 12:05 AM

Java's platform independence means that the code written can run on any platform with JVM installed without modification. 1) Java source code is compiled into bytecode, 2) Bytecode is interpreted and executed by the JVM, 3) The JVM provides memory management and garbage collection functions to ensure that the program runs on different operating systems.

H5: Key Improvements in HTML5 H5: Key Improvements in HTML5 Apr 28, 2025 am 12:26 AM

HTML5 brings five key improvements: 1. Semantic tags improve code clarity and SEO effects; 2. Multimedia support simplifies video and audio embedding; 3. Form enhancement simplifies verification; 4. Offline and local storage improves user experience; 5. Canvas and graphics functions enhance the visualization of web pages.

How to use MySQL functions for data processing and calculation How to use MySQL functions for data processing and calculation Apr 29, 2025 pm 04:21 PM

MySQL functions can be used for data processing and calculation. 1. Basic usage includes string processing, date calculation and mathematical operations. 2. Advanced usage involves combining multiple functions to implement complex operations. 3. Performance optimization requires avoiding the use of functions in the WHERE clause and using GROUPBY and temporary tables.

Composer: The Package Manager for PHP Developers Composer: The Package Manager for PHP Developers May 02, 2025 am 12:23 AM

Composer is a dependency management tool for PHP, and manages project dependencies through composer.json file. 1) parse composer.json to obtain dependency information; 2) parse dependencies to form a dependency tree; 3) download and install dependencies from Packagist to the vendor directory; 4) generate composer.lock file to lock the dependency version to ensure team consistency and project maintainability.

Discuss situations where writing platform-specific code in Java might be necessary. Discuss situations where writing platform-specific code in Java might be necessary. Apr 25, 2025 am 12:22 AM

Reasons for writing platform-specific code in Java include access to specific operating system features, interacting with specific hardware, and optimizing performance. 1) Use JNA or JNI to access the Windows registry; 2) Interact with Linux-specific hardware drivers through JNI; 3) Use Metal to optimize gaming performance on macOS through JNI. Nevertheless, writing platform-specific code can affect the portability of the code, increase complexity, and potentially pose performance overhead and security risks.

See all articles