开发者

Problems with strings in PHP (not adding two strings together properly)

开发者 https://www.devze.com 2022-12-18 23:00 出处:网络
if we say: $termstringDomain1 = \"something\"; $url = \"somethingelse\"; $url = \'http://\' . $termstr开发者_如何学GoingDomain1 . \'/\' . $url;

if we say:

$termstringDomain1 = "something";
$url = "somethingelse";
$url = 'http://' . $termstr开发者_如何学GoingDomain1 . '/' . $url;

the result if gives me is: http:///somethingelse instead of http://something/somethingelse

so basically it is ignoring $termstringDomain1 Any idea why?


I am unable to reproduce this issue:

$foo = "foo";
$bar = "bar";
$bar = "sayFoo: " . $foo . ", sayBar: " . $bar;
print $bar; // 'sayFoo: foo, sayBar: bar'

Your problem is likely elsewhere. If I copy/paste what you provided, I get the following:

http://something/somethingelse

Check your variable casing. $domain1 is not the same as $Domain1.


Can you try putting echo infront of all the declarations, to try to track the problem down?

echo $termstringDomain1 = "something";
echo $url = "somethingelse";
echo $url = 'http://' . $termstringDomain1 . '/' . $url;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号