Remember several basic PHP knowledge points in 20 seconds and basic PHP knowledge in 20 seconds.

Source: Internet
Author: User

Remember several basic PHP knowledge points in 20 seconds and basic PHP knowledge in 20 seconds.

Array:
Index Array: the Key of the array is an integer array, starting from 0.
Join array: the Key of the array is an array of strings.

// Index array $ arr = array ('I', 'love', 'you'); // associate the array $ arr0 = array ('apple' => "apple ", 'yellow' => "yellow ");

Foreach traversal Array

// Array traversal $ arr = array ("apple", "yellow"); foreach ($ arr as $ key = >$ value) {echo '<br> the key is: '. $ key. 'corresponding value :'. $ value ;}$ arr0 = array ('apple' => "apple", 'yellow' => "yellow"); foreach ($ arr0 as $ key =>$ value) {echo '<br> key :'. $ key. ', the corresponding value is :'. $ value ;}

Determine whether a function exists: function_exsits (function name)

Function sayHello () {echo 'hello';} $ test = 'sayhel'; if (function_exsits ($ test) {sayHello ();} // output hello

Constructor: method called when an object is created
Destructor: method called when an object is destroyed

Class Car () {public _ construct () {echo 'object created ';} public _ destruct () {echo 'object destroyed ';}} $ car = new Car ();

Strpos: String SEARCH method

$ Str = 'Hello world'; echo strpos ($ str, 'World'); // output 6, starting from 6th bits

Implode: Return Value: combines array elements into a string.

$ Arr = array ('abc', 'defg'); $ arr0 = implode ('', $ arr); print_r ($ arr0); // The result shows abcdefg.

Explode: Return value: the function returns an array composed of strings.

$ Str = "abc, defg"; $ arr = explode (',', $ str); print_r ($ arr); // The result returns an array with two elements: abc and defg

Author: By: Luo Jian yuan http://blog.csdn.net/sunyuan_software

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.