Udemy REST Assured free

PHP Interview Questions

Showing 1 - 2 of 2 results

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);
}
Subscribe to PHP Interview Questions