PHP mysqli_fetch_object() Function

Object oriented style

object mysqli_result::fetch_object ([ string $class_name = "stdClass" [, array $params ]] )

Procedural style

object mysqli_fetch_object ( mysqli_result $result [, string $class_name = "stdClass" [, array $params ]] )

The mysqli_fetch_object() function returns the current row of a result set, as an object.

The mysqli_fetch_object() will return the current row result set as an object where the attributes of the object represent the names of the fields found within the result set.

Examples -

Object oriented style

Procedural style

The above examples will output:

Pueblo (USA) Arvada (USA) Cape Coral (USA) Green Bay (USA) Santa Clara (USA)

ParameterDescription
resultProcedural style only: A result set identifier returned by mysqli_query(), mysqli_store_result() or mysqli_use_result().
class_nameThe name of the class to instantiate, set the properties of and return. If not specified, a stdClass object is returned.
paramsAn optional array of parameters to pass to the constructor for class_name objects.

Returns an object with string properties that corresponds to the fetched row or NULL if there are no more rows in resultset.