PHP Interview Questions

Displaying 1 - 3 of 3

What is the difference between PHP mysql_fetch_array() and msql_fetch_object() functions?

Both mysql_fetch_array() and mysql_fetch_object() are built-in methods of PHP to retrieve records from MySQL database table.

The difference between these methods is that mysql_fetch_array() returns the result set as an array and mysql_fetch_object() returns the result set as an object.

$result = mysql_query("SELECT id, name FROM clients");

while ($row = mysql_fetch_array($result, MYSQL_NUM)) 
    printf("ID: %s  Name: %s", $row[0], $row[1]);

while ($row = mysql_fetch_object($result))
    printf("ID: %s  Name: %s", $row->id, $row->name);

What are the differences between composer update and composer install?

Here are few key differences:

Point of Difference Composer Update Composer Install
Update and Install latest Dependencies Yes. It read composer.json. Check for latest version of the package and install it. No. Install all dependencies specified in composer.lock file
What if no composer.lock file Create it run composer-update and create it
Update composer.lock? Yes No
When to use? Development Phase Deploying Phase