Posts Tagged with 'PHP'
How do you define a constant in php?
Constant in PHP The define() function is used to defining a constant in PHP define("GREETING", "Welcome to StudyZone4U.com"); Constants are like variables except that once they are defined they cannot be changed or undefined …
What is the difference between explode and split?
The explode() and split() both function is use to split a string into an array. But the difference is explode() function splits a string into array by string where as Split function splits string into …
What is the difference between $name and $$name?
$name and $$name both are variables but with a single difference that is $name is just a normal php variable where as $$name is known as reference variable. It allow you to use $name variable's …
Add number of days to a date in php
PHP | Add numbers of days to a date Simple and easy way to add some days in a given date using strtotime() function. <?php $p_date = "2019-01-10"; echo date('Y-m-d', strtotime($p_date . ' + 1 days')); echo …
What are cookies in PHP?
PHP | What are cookies in PHP? A cookie is a small piece of information store by the browser on the client location and sent to the server with every request. It stores a limited amount …
What is the maximum size of a file that can be uploaded using PHP and how can we change this?
PHP | The maximum size of a file that can be uploaded using PHP The default maximum size of a file that can be uploaded using PHP is 2MB. upload_max_filesize = 2M; and we can …
How can we increase the execution time of a PHP script?
PHP | max_execution_time directive in php.ini file By changing the value of max_execution_time in the php.ini file max_execution_time = 30; // in second By default, the maximum execution time for PHP scripts is set to …
How can we know the number of days between two given dates using PHP?
Bellow code is used for the same $date1 = date(‘Y-m-d’); $date2 = ‘2006-08-15’; $days = (strtotime($date1) – strtotime($date2)) / (60 * 60 * 24); echo $days;
How can we find the number of rows in a result set using PHP?
PHP | Find the number of rows in a result set Bellow code is use for the same $sql = "SELECT * FROM table1"; $result = mysql_query($sql, $db_link); $num_rows = mysql_num_rows($result); echo $num_rows;
What are the predefined classes in PHP?
Predefined classes in PHP are: Directory stdClass __PHP_Incomplete_Class exception php_user_filter
How can we find or count number of elements in an array?
PHP | Count number of elements in an array There are two ways to find the number of elements in an array: 1. sizeof($arr), This function is an alias of count() echo sizeof($arr); 2. count($arr) echo …
What are the difference between mysqli_fetch_assoc and mysqli_fetch_array?
PHP-MYSQL | mysqli_fetch_assoc() VS mysqli_fetch_array() mysqli_fetch_assoc() function fetch a result row as an associative array where as mysqli_fetch_array() function fetch a result row as an associative array, a numeric array, or both. mysqli_fetch_assoc() The mysqli_fetch_assoc() …
What are the difference between mysqli_fetch_object and mysqli_fetch_array?
PHP-MYSQL | mysqli_fetch_object () VS mysqli_fetch_array() mysqli_fetch_object() fetch a result row as an object where as mysqli_fetch_array() fetch a result row as an associative array, a numeric array, or both. mysqli_fetch_object() The mysqli_fetch_object() function returns …
how many ways we can retrieve the data in the result set of MySQL using PHP?
PHP-MYSQL | Fetch Recoards From MySql table There are 4 ways: mysqli_fetch_row() - Get a result row as an enumerated array mysqli_fetch_array() - Fetch a result row as an associative array, a numeric array, or both mysqli_fetch_object() …
Give an example of Transaction with commit and rollback?
PHP-MySQL | Transaction with commit and rollback try { // First of all, let's begin a transaction $db->beginTransaction(); // A set of queries; if one fails, an exception should be thrown which we are handling at …