Если мы говорим [приблизительно 111] Запрос заголовки, можно создать собственные заголовки при выполнении XmlHttpRequests.
var request = new XMLHttpRequest();
request.setRequestHeader("X-Requested-With", "XMLHttpRequest");
request.open("GET", path, true);
request.send(null);
Sure you can, but unfortunately, you need to use call_user_func()
to achieve this:
require_once 'template.php';
foreach (array("javascript","script","css") as $tag) {
echo call_user_func('template\\'.$tag);
}
Namespaces in PHP are fairly new. I'm sure that in the future, they will fix it so we won't require call_user_func()
anymore.
Это также будет работать, нет необходимости в call_user_func
, просто используйте Variable functions Docs feature:
require_once 'template.php';
$ns = 'template';
foreach (array('javascript', 'script', 'css') as $tag) {
$ns_func = $ns . '\\' . $tag;
echo $ns_func();
}
try with
// Main php file
require_once 'template.php';
foreach (array("javascript","script","css") as $tag) {
call_user_func("template\\$tag"); // As of PHP 5.3.0
}
// template.php
namespace template;
function javascript() { return "Hello from javascript"; }
function css() { return "Hello from css"; }
function script() { return "Hello from script"; }
you have some info here