Using the PHP Function pg_field_is_Null()
As a PHP programmer, you will often find yourself relying on built-in functions to perform the many tasks you will be faced with. When writing code, it is important to understand how these functions work and their scope. If you don’t, your scripts may be prone to bugs and errors.
Functions in PHP are a great way to decouple code, so that multiple pieces of logic can be performed on the same data. This is done by passing information to the function through its arguments. Arguments are specified after the function name and within the parentheses. Generally, each argument must be of the same data type as the function, but PHP also allows for a variable to be passed by reference. When doing this, the function adds a new entry to its symbol table that references the internal data structure that holds the variable’s value and type.
The pg_field_is_null() function tests if a field in a PostgreSQL result resource is SQL NULL or not. It accepts a row number in the range (numbered from 0 upwards), the field number in the row (0 or name) and return 1 if the field is SQL NULL or FALSE upon any error.
In PHP 7 you can enable a strict type for the function return statement. When enabled, this will prevent the function from performing type juggling on its arguments and will throw a fatal error if the return argument is not of the same type as the function argument.