PHP code example of fer79 / php-optional-helper
1. Go to this page and download the library: Download fer79/php-optional-helper library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fer79 / php-optional-helper example snippets
optional($obj)->prop
optional($obj)->method()
optional($array)['key']
optional($value)->get()
echo optional($value);
null → ""
string / int / float / bool → converted to string
arrays / objects → JSON