💡 To learn WordPress Theme and Plugin development, the following PHP topics would be more than sufficient. This PHP for WordPress guideline is provided by Kamal Ahmed, who has worked for WPDevelopers, rtCamps, UberSuggest, SiteCare, and other companies.
- Variables & Data Types: (string, integer, float, array, object). Minimum 15 array functions & 10 string functions.
- Functions and Scopes.
- Loops (for, foreach, while) & Conditions (if, else, switch, try catch).
- Working with FORMS: get, post, delete, put difference. Validating and Escaping user submitted data.
- Global variables: GET, POST, REQUEST differences and usage.
- Include and Require
- For Object Oriented PHP:
- Class,
- Object,
- Class property,
- Class method,
- Visibility,
- Static,
- Inheritance
- A little intermediate or relatively less common topics but very important and found sometimes in plugins and themes.
- Interface, traits, Singleton, Magic Methods, Namespace etc.
- Output Buffering, SESSION, COOKIES, Working with APIs using curl. Date and Times,
- Working with files (opening, reading, writing etc)
The most commonly used Functions for manipulating Arrays in PHP.
Please see the documentation for example and details understanding.
Array Functions in PHP
sizeof($array)
: Use this function to find out how many elements an array containsarray_values($array)
: Use this function to retrieve all the values from an associative array.array_keys($array)
: Use this function to retrieve all the keys from an associative array.array_pop($array)
: Use this function to remove an element from the end of an array.array_push($array, $value)
: This function adds an element to the end of an array.array_shift($array)
: This function removes an element from the beginning of an array.array_unshift($array, $value)
: This function adds an element to the beginning of an array.array_map($callback, $array1)
: This function returns an array containing all the elements of array1 after applying the callback function to each one. You can pass more than one array. The number of parameters that the callback function accepts should match the number of arrays passed to the array_map()sort($array)
: This function sorts the elements of an array in ascending order. String values will be arranged in ascending alphabetical order. Other sorting functions includeasort()
,arsort()
,ksort()
,krsort()
andrsort()
.array_reverse($array)
: This function reverses the order of elements in an array.array_merge($array)
: Use this function when you need to combine data from two or more arrays into a single structurearray_rand($array)
: This function selects one or more random elements from an array.array_search($search, $array)
: This function searches the values in an array for a match to the search term, and returns the corresponding key if found. If more than one match exists, the key of the first matching value is returned.array_slice($array, $offset, $length)
: Use this function to break a larger array into smaller ones.array_unique($array)
: Use this function when you need to remove non-unique elements from an arrayextract($array)
: Import variables into the current symbol table from an array. For Better understanding read the doc about this function. It is very nice. Its opposite iscompact()
.array_key_exists($key, $array)
: This functions returns TRUE if the given key is set in the array.in_array($searched_value, $array)
: This functions returns TRUE if the given value exists in the array
The most commonly used Functions for manipulating Strings in PHP
substr()
: This function returns the part of the string as an output.strlen()
: This function returns the length of the stringtrim()
: This function removes the white-spaces from both start and the end of the string.ltrim()
: This function removes the white-spaces from the left part of the string.rtrim()
: This function removes the white-spaces from the right part of the string.strtolower()
: This function converts the string to lower casestrtoupper()
: This function converts the string to upper casestr_replace()
: The str_replace() function replaces some characters with some other characters in a string.explode()
: This function breaks the string into array on the basis of delimiter passed.implode()
: This function join array elements with a string on the basis of delimiter passed.
Resources
- PHP for Beginners (2023 Edition) by Jeffery Way
- Learn PHP The Right Way by Gio
Leave a Reply