My main script has a namespace of "App". I have imported another PHP script into my main script.
My main script thinks the function is part of App... when it's not. It's in the other PHP script.
How do I access functions that are outside of the namespace?
First option is to import the namespace on that particular php file then you can alias; meaning u tell php that u will reference an imported class, interface, function, or constant with a shorter name. As of PHP 5.6 it's possible to import functions and constants. This requires a tweak to use the keyword syntax. To import a function:
<?php
use func Namespace\functionName;
functionName();
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.