SimpleXML 函数中罕见的数组变量索引
我在表单选择上有一个标签,我用 $ _POST 得到这个值,如下所示:
$gallery = array($_POST['gallery']);
并且该值将把它放在这里:
$image = $sitemap->gallery[$gallery]->addChild('image');
问题是给我错误如下:
Fatal error: Call to a member function addChild() on a non-object in
我不明白的是,如果我直接输入一个值我这样做:
$gallery = 0;
$Image = $sitemap->gallery[$gallery]->addChild('image');
我做得很好,发生的事情是我希望用户选择, 有点奇怪,因为它可能会修复。
I have a label on a form select and I get that value with $ _POST like this:
$gallery = array($_POST['gallery']);
and that value will put it here:
$image = $sitemap->gallery[$gallery]->addChild('image');
the problem is giving me error is as follows:
Fatal error: Call to a member function addChild() on a non-object in
I do not understand is that if I put a value directly asin me do it like so:
$gallery = 0;
$Image = $sitemap->gallery[$gallery]->addChild('image');
I do well, what happens is that I want the user to choose,
Kind of strange as it may fix.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
了解数组:
输出:
如何从数组中获取值:
添加自定义索引
输出:
Array
从客户索引数组中获取值
Understanding Arrays:
Output:
How to get the value out of an array:
Adding a custom index
Output:
Array
Getting the value from the customer index array
使用这个:
而不是这个:
您传递了一个没有正确索引的数组
或者您可以尝试这种方式:
或者
任何一种方式都可以解决问题
use this:
instead of this:
You passing an array that you did not index properly
Or you can try it this way:
or
either way should fix the problem
非常感谢,但我对此进行了测试,并给了我同样的错误
,我不明白我的选择形式如下:
无论如何,我已经尝试了回显,我得到了结果,不太明白
thank you very much, but I tested this and is giving me the same error
I do not understand the select form that I have is as follows:
anyway I've tried has done an echo and I get the result, do not really understand