php 连接

发布于 2024-12-05 11:24:46 字数 363 浏览 0 评论 0原文

我有一个名为 $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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

前事休说 2024-12-12 11:24:46

我无法重现这种行为(使用 PHP 5.3.3-7),也许问题出在代码的另一部分(您可能需要发布代码的更大部分来帮助我们查看问题所在)。

以下代码段:

<?php
$eventview=3;
$eid=1;
$link="option=com_zcalendar&vmode=e&view=".(string)$eventview."event&format=html&tmode=m&eid=$eid";
echo $link;
?>

产生以下输出:

option=com_zcalendar&vmode=e&view=3event&format=html&tmode=m&eid=1

尝试在评估$link之前打印$eventview的值。

正如 Firas Jradi 所提到的,简单地使用:

$link="option=com_zcalendar&vmode=e&view=".$eventview."event&format=html&tmode=m&eid=$eid";

也可以(这将是我的第一次尝试,尽管我对 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:

<?php
$eventview=3;
$eid=1;
$link="option=com_zcalendar&vmode=e&view=".(string)$eventview."event&format=html&tmode=m&eid=$eid";
echo $link;
?>

produces the following output:

option=com_zcalendar&vmode=e&view=3event&format=html&tmode=m&eid=1

Try to print the value of $eventview just before evaluating $link.

As mentionned by Firas Jradi, simply using:

$link="option=com_zcalendar&vmode=e&view=".$eventview."event&format=html&tmode=m&eid=$eid";

works as well (and would have been my first try, although I'm not that familiar with PHP types).

墨落画卷 2024-12-12 11:24:46
<?php
$eventview = 3;
$eid  = "helo";
$k = "option=com_zcalendar&vmode=e&view=" .(string)$eventview. "event&format=html&tmode=m&eid=".$eid;
echo $k;
?>
here only problem is you are not declareing another variable last written in     line
<?php
$eventview = 3;
$eid  = "helo";
$k = "option=com_zcalendar&vmode=e&view=" .(string)$eventview. "event&format=html&tmode=m&eid=".$eid;
echo $k;
?>
here only problem is you are not declareing another variable last written in     line
つ低調成傷 2024-12-12 11:24:46

您是否尝试过不使用显式转换?

$link="option=com_zcalendar&vmode=e&view=".$eventview."event&for...

have you tried not to use the explicit casting?

$link="option=com_zcalendar&vmode=e&view=".$eventview."event&for...
热血少△年 2024-12-12 11:24:46

确认 $eventView 确实有值后 - 尝试将这一部分更改

" .(string)$eventview. "

" .((string)$eventview). "

Also

Try Change this line $eventview=3;

$eventview='3';

引号或双引号。

请注意:我还没有测试过,只是一个建议。

After you have confirmed that $eventView does have a value - try changing this piece

" .(string)$eventview. "

to

" .((string)$eventview). "

Also

Try changing this line $eventview=3;
to

$eventview='3';

i.e. quotes or double quotes around it.

Please note: I haven't tested it but just a suggestion.

↘人皮目录ツ 2024-12-12 11:24:46

正如@Wbdvlpr建议的那样,我认为添加另一组括号可以解决问题,这有时会发生在串联中。老实说,我不记得我的上面有这方面的规则。

尝试一下也没什么坏处;-)

$str = 'dsadas dsadsa dasdasda'.((string) $myString).' dsadasdas';

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 ;-)

$str = 'dsadas dsadsa dasdasda'.((string) $myString).' dsadasdas';
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文