I'm new to PHP namespaces, what I have is:
namespace Foo\Bar;
class JsonAssetRest{
static function ini(){
$headers = getallheaders();
}
}
JsonAssetRest::ini();
And this is creating the error
Uncaught Error: Call to undefined function Foo\Bar\getallheaders() in /var/www/html/class JsonAssetRest.php
How do I use getallheaders() (the built in function) without getting this error?
Edit: The issue was related to removing a library while I was converting my code to a namespaced class. Said library defined getallheaders for nginx. I was confused by the error message adding namespacing and thought that was the issue.
Gonna leave this up in case someone else gets confused by the error while debugging. And because the comments have improved my understanding of namespacing in PHP.
Edit2: In case someone stumbles upon this error and wants to know how to solve the actual problem (getallheaders not being defined under nginx), it's been answered here: Get the http headers from current request in PHP