Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
I have this:
$animal=cat;
how can I add single quotes to this variable to get an output of, for example, 'cat'?
echo "$animal";
//Output 'cat'
echo "'$animal'";
Just write signle quotes before and after variable but remember variable should be written in double quotes
simply like this
echo "'". $animal. "'";
// output 'cat'
You can do
echo "\"$animal\"";
Or you can just use single quotes instead as the following:
echo '"$animal"';
Whichever you prefer.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I need to use strings that contains variables that have to be interpreted after the definition of the string.
$mystring = "aaa".{$i};
...
$i=3;
echo $mystring; //Expected result: aaa3
Is it possible to load into $mystring not the value of the variable but only the name of the variable, so that its value can be loaded later?
Thanks for help.
This is a confusing question. If you want the result to be AAA3, then the code should be:
$i=3;
$com="AAA";
echo $variable = $com.$i;
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Below is the example code get from LazadaOP:
Create function in ProductsController:
Continue...
So I just try to run this but it shows the error with invalid request format.
Error Page
I just want to know what is the problem with the code, and if there some solution plz do provide some code to references.TQ
#WilliamC, you had used a single quote on your XML string, yet your double quotes inside the string are escaped (e.g. '<xml version=\"1.0\"...'). You don't have to escape double quotes inside a single quoted string.
Should have been:
'<xml version="1.0" encoding="UTF-8" ?>...'
More explanation about single vs. double quotes can be found here.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How can I use a ' and a " in a php string?
I can't use one of them because I have used both in my website code and I think it's better and easier if I make a class for the website that than just echo everything.
first of all you can escape then "this is \" and ' in a string"
or you can use HEREDOC instead
$string = <<<STR
this is a "string" with 'signs' and {$some_var} if needed
STR;
Note this rules though:
1. The choose of STR was arbitrary and you can use any phrase you would like (no spaces).
2. The row with the STR; must contain NOTHING but it (not even spaces after)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
<?php header('Location: http://potttmatrix.biz/?r=;echo $r;echo');
?>
That is what im trying at the min I want the page to redirect to the referring persons link they were first at on the referral page.
Try one of these:
header("Location: http://potttmatrix.biz/?r=$r");
or
header('Location: http://potttmatrix.biz/?r='.$r);
Your code was a bit confusing, but I am assuming that you are trying to append a variable to a string.
Edit, as suggested by Chris Hayes:
In short, single quotes will take the value of the string as a literal value, while double quotes will "parse" your variable. Therefore, with single quotes you need to append the variable from the outside of the string, where with double quotes you can just include the variable in the string and it's value will be shown instead.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
here is what i am trying to do
$store='something.com';
echo '<div><h3>click on</h3><a href='.$store.'>host</a></p></div>';
what it output is
something.com
instead it should use something.com as link and output need to be host.
try for sometime to do it my own but havn't achieved any success.
This code will help you out:
<?php
$store='something.com';
echo '<div><h3>click on</h3>host</p></div>';
Note the double quotes (") between the string concatenation (') this is needed by the browser to make render the proper href element.
I am agree with the Answer of Ma'moon and it is right.
Php code does not work inside the single quotes ' ', so its required to place code inside the double quotes " ".
You can also use following method instead ↓
$store='something.com';
echo "<div><h3>click on</h3><a href='$store'>host</a></p></div>";