getimagesize() is used to get image size and imagesx() to fetch image width and imagesy() to fetch height.
Both the functions,’require’ and ‘include’ are used to include the files in PHP. However If the file does not exists in server then require throws fatal error and code executions is terminated. On the other hand, if file is not found and include function is used, it throws warning and rest of the code still continues to execute.
Both functions require and require_once are used to include file in PHP page, but the difference is that reurie_once checks if the file is already included or not. If yes then it shows warning.
print_r() is used to display the content of any array.
We can solve this problem by two ways. Either we can include ‘set_time_limit(time here)’ at the beginning of PHP page.
Or if the php.ini file is accessible, we can increase ‘maximum_execuation_time’ from there also.
There is a function called error_reporting() where we can decide if we want to display error or supress it. We write error_reporting(0) . That means all warnings, notices and errors will be supressed. However if we want to display error only, and not notices and warning then we can write error_reporting(E_ERROR).
explode() function convert any string with delimiter into Array.Explode is used to split a string using another string.
Example :explode (” this”, “this is a string”); //will return “Is a string”
The split() function splits the string into an array using a regular expression and returns an array.
Example :split(‘:India:Pakistan:Srilanka’);
Returns and array
Explode Example:explode(‘and’,‘India and Pakistan and Srilanka’);
Returns and array
file_get_contents() is used to extract the html code of other file and then it is stored in a string format in any variable.
MySql is an old database engine whereas MySqli is the improved database engine. ‘i’ means improved. MySqli supports prepared statement which prevents SQL injection for hackers.
Both, mysql_connect and mysql_pconnect() are used for database connection but the difference is that mysql_connect closes database connection once the PHP code is executed .On the other hand,mysql_pconnectensures a persistent connection to the database, that means the connection is still on even if the code is executed.
Mysql_pconnect is deprecated and is not supported by php 7.0 and above.
There are following ways of result set ‘mysqli_fetch_array’, ‘mysqli_fetch_assoc’, ‘mysqli_fetch_object’ or ‘mysqli_fetch_row’.
The function mysqli_num_rows() returns the number of rows in a result set.
‘DISTINCT’ keyword is used to eliminate duplicate values and show only the unique records.
The mysqli_fetch_object() function returns the first single matching record on the other handmysqli_fetch_array() returns all matching records from the table in an array.
GET and POST are two methods to send data. But the main difference is that data sent through get method is passed via URL and is visible to all. Whereas, data posted using POST method is sent hidden and is not visible to anyone.
In the post method, field names and its values are clubbed together to form an associative array and the data is sent to server in the form of Associative array.
Primary key is a ‘constraint’ in which no duplicate and no null values are allowed. Unique key is also same but it can accepts one null value.
PHP has built in function for this to check whether the given number is alphanumeric. The function name is ctype_alnum to check whether it is an alphanumeric value or not.
To upload Image or any file, there is built-in PHP function called move_uploaded_file()
It takes two parameters. The first parameter is files temp name and in the second parameter the actual file name along with the folder name.
The unlink() function is used to delete file from server.
Classroom
Online
WeekEnd