Jump to content

Variable Question


foochuck

Recommended Posts

My first variable is named $charlie and the second one is called $myBlog

 

I would like to make $myBlog = $charlie and append the word info to my $charlie variable so that $myBlog = $charlieInfo;

 

I'm not sure how to write this. I have tried:

 

$myBlog = $charlie . "Info"; but that didn't turn out the way I was hoping.

 

Could someone show me the correct syntax for this?

 

 

Link to comment
https://forums.phpfreaks.com/topic/112834-variable-question/
Share on other sites

not sure what you're asking. If you append data, like this:

<?php
$charlie = "charlie";
$myBlog = $charlie."info";
print $myBlog;
?>

you get

charlieinfo

That, I know you understand.

Next: If you rename the variable, so it becomes this:

<?php
$charlie = "charlie";
$myBlog = $charlieinfo;
print $myBlog;
?>

you'll get errors.  So, Could you explain what it is that you're wanting?

Link to comment
https://forums.phpfreaks.com/topic/112834-variable-question/#findComment-579532
Share on other sites

Actually I have though of another way to do what I'm trying to do - but I still need help.

 

I'm trying to pass a variable through a URL - using the get method - however I want to pass one variable another variables name and I'm not sure how to do this.

 

$myVar = "This is it";

 

http://mysite.com?myBlog=myVar

 

Basically in the end, I want $myBlog to be idential to $myVar (the string "This is it")

 

okay...so, do you want $charlieinfo to have the same info as $charlie?  Assuming you do..

 

$info = "info"; 
$charlie = "some piece of data";
$charlie.$info = $charlie;

echo $charlieinfo;

Link to comment
https://forums.phpfreaks.com/topic/112834-variable-question/#findComment-580130
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.