PHP code example of withinboredom / nameof
1. Go to this page and download the library: Download withinboredom/nameof 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/ */
withinboredom / nameof example snippets
enum Foo {
case Bar;
case Baz;
}
$arr = [];
$arr[nameof(Foo::Bar)] = 1; // resolves to 'Bar'
$var = 1;
$bar = 2;
echo (compact(nameof($var), nameof($bar))); // ['var' => 1, 'bar' => 2]
echo nameof(1); // 1
echo nameof($myCallback(...)); // myCallback
echo nameof($x->prop); // prop
echo nameof($x->prop->fun(...)) // fun