note 125366 added to function.class-exists

From: Date: Wed, 16 Sep 2020 06:54:19 +0000
Subject: note 125366 added to function.class-exists
Groups: php.notes 
Request: Send a blank email to php-notes+get-215118@lists.php.net to get a copy of this message
Note: class_exists() check only classes! <?php interface DemoInterface {}; var_dump(class_exists('DemoInterface')); // false trait DemoTrait {}; var_dump(class_exists('DemoTrait')); // false class DemoClass {}; var_dump(class_exists('DemoClass')); // true ?> Common function: <?php /** * Checks if the class/trait/interface has been defined. * * @param string $name The case-insensitive name of class/trait/interface * @param bool $autoload Whether to call spl_autoload() * @return bool */ function structure_exists(string $name, bool $autoload = true): bool { return class_exists($name, $autoload) || interface_exists($name, $autoload) || trait_exists($name, $autoload); } ?> ---- Server IP: 45.112.84.4 Probable Submitter: 103.51.167.36 (proxied: 31.129.215.166) ---- Manual Page -- http://php.net/manual/en/function.class-exists.php Edit -- https://master.php.net/note/edit/125366 Del: integrated -- https://master.php.net/note/delete/125366/integrated Del: useless -- https://master.php.net/note/delete/125366/useless Del: bad code -- https://master.php.net/note/delete/125366/bad+code Del: spam -- https://master.php.net/note/delete/125366/spam Del: non-english -- https://master.php.net/note/delete/125366/non-english Del: in docs -- https://master.php.net/note/delete/125366/in+docs Del: other reasons-- https://master.php.net/note/delete/125366 Reject -- https://master.php.net/note/reject/125366 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#215118) next »