What does double question mark (??) operator mean in PHP

It’s the “null coalescing operator”, added in php 7.0. The definition of how it works is: It returns its first operand if it exists and is not NULL; otherwise it returns its second operand. So it’s actually just isset() in a handy operator. Those two are equivalent1: Documentation: http://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.coalesce In the list of new PHP7 features: http://php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op And original … Read more

How to convert array to SimpleXML

a short one: results in keys and values are swapped – you could fix that with array_flip() before the array_walk. array_walk_recursive requires PHP 5. you could use array_walk instead, but you won’t get ‘stack’ => ‘overflow’ in the xml then.

How to extract and access data from JSON with PHP?

Intro First off you have a string. JSON is not an array, an object, or a data structure. JSON is a text-based serialization format – so a fancy string, but still just a string. Decode it in PHP by using json_decode(). Therein you might find: scalars: strings, ints, floats, and bools nulls (a special type … Read more

Difference between require, include, require_once and include_once?

There are require and include_once as well. So your question should be… When should I use require vs. include? When should I use require_once vs. require The answer to 1 is described here. The require() function is identical to include(), except that it handles errors differently. If an error occurs, the include() function generates a warning, but the script will continue execution. The require() generates a … Read more

What is the advantage of using try {} catch {} versus if {} else {}

I’d use the try/catch block when the normal path through the code should proceed without error unless there are truly some exceptional conditions — like the server being down, your credentials being expired or incorrect. I wouldn’t necessarily use it to handle non-exceptional errors — say like the current user not being in the correct … Read more

How to extract and access data from JSON with PHP?

Intro First off you have a string. JSON is not an array, an object, or a data structure. JSON is a text-based serialization format – so a fancy string, but still just a string. Decode it in PHP by using json_decode(). Therein you might find: scalars: strings, ints, floats, and bools nulls (a special type … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)