如果我.通过$ _GET PHP在其名称中传递PHP变量,则自动用_字符替换它们.例如:
<?php
echo "url is ".$_SERVER['REQUEST_URI']."<p>";
echo "x.y is ".$_GET['x.y'].".<p>";
echo "x_y is ".$_GET['x_y'].".<p>";
Run Code Online (Sandbox Code Playgroud)
...输出以下内容:
url is /SpShipTool/php/testGetUrl.php?x.y=a.b
x.y is .
x_y is a.b.
Run Code Online (Sandbox Code Playgroud)
......我的问题是这样的:有什么方法可以阻止它吗?不能为我的生活弄清楚我做了什么值得这样做
我运行的PHP版本是5.2.4-2ubuntu5.3.
我有以下数组:
$conf = array(
'db' => array(
'server' => 'localhost',
'user' => 'root',
'pass' => 'root',
'name' => 'db',
),
'path' => array(
'site_url' => $_SERVER['SERVER_NAME'],
'site_dir' => CMS,
'admin_url' => conf('path.site_url') . '/admin',
'admin_dir' => conf('path.site_dir') . DS .'admin',
'admin_paths' => array(
'assets' => 'path'
),
),
);
Run Code Online (Sandbox Code Playgroud)
我想使用像这样的函数从这个数组中获取一个值:
/**
* Return or set a configuration setting from the array.
* @example
* conf('db.server') => $conf['db']['server']
*
* @param string $section the section to return the setting from.
* …Run Code Online (Sandbox Code Playgroud) 我在使用PHP创建递归数组时遇到问题.
我需要将此字符串格式化为多维数组,其中以点分隔的元素表示多个级别的数组键.
$str = "code.engine,max_int.4,user.pre.3,user.data.4";
Run Code Online (Sandbox Code Playgroud)
此示例的输出将是:
$str = array(
"code" => "engine",
"max_int" => 4,
"user" => array(
"pre" => 3,
"data" => 4
)
);
Run Code Online (Sandbox Code Playgroud)
我将从一个explode函数开始,但我不知道如何从那里对它进行排序,或者如何完成foreach.