php 连接
我有一个名为 $eventview 的变量,值为 3。 我尝试在此链接中添加值:
$link = "option=com_zcalendar&vmode=e&view=" .(string)$eventview. "event&format=html&tmode=m&eid=$eid";
但该链接始终
option=com_zcalendar&vmode=e&view=event&format=html&tmode=m&eid=355
没有 eventview 值。请问有谁可以帮助我吗???
I have a var named $eventview with value of 3.
I trying to add the value in this link:
$link = "option=com_zcalendar&vmode=e&view=" .(string)$eventview. "event&format=html&tmode=m&eid=$eid";
But the link is always
option=com_zcalendar&vmode=e&view=event&format=html&tmode=m&eid=355
with out the eventview value. Does any body can help me, please???
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
我无法重现这种行为(使用 PHP 5.3.3-7),也许问题出在代码的另一部分(您可能需要发布代码的更大部分来帮助我们查看问题所在)。
以下代码段:
产生以下输出:
尝试在评估
$link
之前打印$eventview
的值。正如 Firas Jradi 所提到的,简单地使用:
也可以(这将是我的第一次尝试,尽管我对 PHP 类型不太熟悉)。
I could not reproduce this behavior (with PHP 5.3.3-7), maybe the problem lies in another part of your code (you may want to post a bigger part of your code to help us see what is wrong).
The following piece of code:
produces the following output:
Try to print the value of
$eventview
just before evaluating$link
.As mentionned by Firas Jradi, simply using:
works as well (and would have been my first try, although I'm not that familiar with PHP types).
您是否尝试过不使用显式转换?
have you tried not to use the explicit casting?
确认 $eventView 确实有值后 - 尝试将这一部分更改
为
Also
Try Change this line
$eventview=3;
即
引号或双引号。
请注意:我还没有测试过,只是一个建议。
After you have confirmed that $eventView does have a value - try changing this piece
to
Also
Try changing this line
$eventview=3;
to
i.e. quotes or double quotes around it.
Please note: I haven't tested it but just a suggestion.
正如@Wbdvlpr建议的那样,我认为添加另一组括号可以解决问题,这有时会发生在串联中。老实说,我不记得我的上面有这方面的规则。
尝试一下也没什么坏处;-)
As @Wbdvlpr suggested i think adding another set of brackets will solve the problem, this sometimes happens in concatenation. I honestly don't remember the rules on this on the top of my had.
Wouldn't hurt trying ;-)