homepage Welcome to WebmasterWorld Guest from 54.161.155.142
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
defining a variable
mixing a variable and a string
KrazyKid




msg:1277904
 8:37 pm on May 9, 2005 (gmt 0)

This is what I need to do:
$filename = '$member' + '.inc';
How do I do this? Thanks

 

bcolflesh




msg:1277905
 8:52 pm on May 9, 2005 (gmt 0)

$filename = $member.'.inc';

kazecoder




msg:1277906
 9:52 pm on May 9, 2005 (gmt 0)

I just wanted to add that what you are asking about is know as concatenating strings. The above will fix you up just right.

KrazyKid




msg:1277907
 12:51 am on May 10, 2005 (gmt 0)

thanks :)

KrazyKid




msg:1277908
 3:55 am on Jun 5, 2005 (gmt 0)

How do I do this correctly?
echo '$game' + '/' + '$filename';
Thanks

ekram




msg:1277909
 5:03 am on Jun 5, 2005 (gmt 0)

How do I do this correctly?
echo '$game' + '/' + '$filename';
Thanks

<?
echo $game . '/' . $filename;
?>

base64




msg:1277910
 5:58 pm on Jun 5, 2005 (gmt 0)

One more way:

echo "$game/$filename";

mcibor




msg:1277911
 8:29 pm on Jun 5, 2005 (gmt 0)

If you echo the variable between ' ' then it is put as string. If you put it between " " then it is parsed as a variable:

<?php
$var = "This is a test";
echo 'This is a variable: $var<br>';
echo "This is what is inside: $var";
?>

Also to ensure that you are doing everything correctly you can put the variable outside of the string:

echo "This is what is inside: ".$var."<br>";

As you see the concatenation in php is a dot (not plus as in javascript).
Best regards
Michal Cibor

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved