The is a very simple echo statement but I can't solve it?
echo '"What is your name?'";
Mismatch of single quotes, use this:
echo '"What is your name?"';
Your first enclosing character was single quote but ending one was double quote causing the problem
Incorrect:
echo '"What is your name?'";
^ Unexpected character
Correct:
echo '"What is your name?';
Correct:
echo "What is your name?";
Correct:
echo 'What is your name?';
Correct:
echo '"What is your name?"';
Correct:
echo "'What is your name?'";
Your quotes are nested incorrectly.
echo "\"What is your name?\"";
This is where your interpreter is choking:
echo '"What is your name?'";
expecting ; not "
echo "What is your name?";
This is Simply the best. No confusion No problem..:)
Related
i have this problem i hope some of you can help me with. I try to make a html link that get the link from my database.
echo "<p><pre><a href=$Feed['socialfacebook']><img src=facebook-24.png></a></pre></p>
You need to put the link in '".$variable ."' and the image src should be in ' ', too.
echo "<p><pre><a href='".$Feed['socialfacebook']."'><img src='facebook-24.png'></a></pre></p>";
Double-quoted strings don't work with array elements quite like that. You should close and concatenate the strings.
echo "<p><pre><img src=facebook-24.png></pre></p>"
You might also want to put some quotes on your attributes.
Close your string with a double quote and end your statement with a semi-colon,
When getting array elements inside a string literal like you're doing, leave out the key quotes,
Use single quotes around your attribute in case of any spaces:
echo "<p><pre><a href='$Feed[socialfacebook]'><img src=facebook-24.png></a>";
Eval.in
u need to put the variable $Feed['socialfacebook'] in " . $Feed['socialfacebook'] ."
echo "<p><pre><a href=" . $Feed['socialfacebook'] . "<img src=facebook-24.png></a></pre></p>";
and don't forget the ;
Shouldn't it be:
echo "<p><pre><a href='$Feed["socialfacebook"]'><img src=facebook-24.png></a>";
Don't forget that is href="".
Hi i have been using this php echo statement
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."'"."onclick='return
confirm(/Are you sure, you want to delete?/)'>Delete</a>";
The statement is working i am seeing this message /Are you sure, you want to delete?/ instead of this Are you sure, you want to delete?
Your quote nesting is a little messed up. Try to follow these rules:
Outer quote = " (This marks the beginning and end of the string)
Inner quote = \" (Escaped as to not flag "beginning/end of string")
Third-tier quote = ' (Literal quote)
Fourth-tier quote = \' (Literal quote that will be generated as an escaped outer quote)
Result:
echo "<a href=\"message_delete_script_outbox.php?id=".$row['id']."\"onclick=
\"return confirm('Are you sure, you want to delete?')\">Delete</a>";
More info about quote nesting: http://blog.opensourceopportunities.com/2007/10/nested-nested-quotes.html
You enclose the message in quotes, and those quotes need to be escaped to avoid confusing the PHP script:
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."'"."onclick='return
confirm(\"Are you sure, you want to delete?\")'>Delete</a>";
Just add double quotes and escape them
echo "<a href = 'message_delete_script_outbox.php?id=".$row['id']."' onclick='return confirm(\"Are you sure, you want to delete?\")'>Delete</a>";
I am not sure if you added a new line when you posted here, but you should know you cannot have that script on 2 lines.
I cant get this to work and its driving me mad, pls help
echo "<a href='#' onclick='javascript:$.jGrowl
(\"".$_SESSION['product_description'][$i]."\")' >?</a>";
the problem comes down to the 'product_description' - those single ' marks are breaking it, what should i do sigh
EDIT: if i replace the .$_SESSION['product_description'][$i]. with a bunch of charecters it works, its not a problem with anything but PHP and those ''
Chances are the real problem lies with the $.jGrowl. Within double quotes, PHP tries to parse found variables. e.g.
$foo = 'foo';
echo "This is foo: $foo"; // output: This is foo: foo
So, to avoid this you need to escape the $ using \$ within the string...
echo "...\$.jGrowl..."
See this demo.
Keep this here for reference:
Escape them with a backslash, like you would with double quotes. e.g.
// which ever quote is used to encapsulate the string
// must be escaped within the output.
echo 'Hello, \'world!\''; // output: Hello, 'world!'
echo "Hello, \"world!\""; // output: Hello, "world!"
// but, if you use the opposite quote, it does not need
// to be escaped for output.
echo 'Hello, "world!"'; // output: Hello, "world!"
echo "Hello, 'world!'"; // output: Hello, 'world!'
See the PHP Docs on strings for more information and what characters need escaping.
Are you missing your opening "?
echo "<a href='#' onclick='javascript:$.jGrowl(\"".$_SESSION['product_description'][$i]."\")' >?</a>";
Make it
echo "<a href='#' onclick='javascript:$.jGrowl(\"".$_SESSION['product_description'][$i]."\")' >?</a>";
Try:
echo "<a href='#' onclick='javascript:\$.jGrowl(\"".str_replace('"','\"',$_SESSION['product_description'][$i])."\");' >?</a>";
You need to ensure you are escaping any double quotes within the value...
This one works for me:
echo "<a href=\"#\" onclick=\"javascript:$.jGrowl('".$_SESSION['product_description'][$i]."')\" >?</a>";
I am trying to print a variable between curly braces as
Product_number{product_version}
I tried
echo "$product_number{$product_version}";
But that does not work. I don't understand why :(
try using double braces:
echo "$product_number{{$product_version}}";
You can also do:
echo "$product_number{".$product_version."}";
{ followed by $ is treated specially. It is mainly used when you want to append a string immediately at the end of a variable's value:
$v = 'hack';
echo "I {$v}ed it";
echo $product_number . "{" . $product_version . "}";
Escape the "{":
echo "$product_number\{$product_version}";
In html source
\xE6\x82\xA0
result is "\xE6\x82\xA0"
but in php
<?php echo "\xE6\x82\xA0"; ?>
result is "悠" (character for \xE6\x82\xA0 )
what can be done to make php echo \xE6\x82\xA0?
If you want to print the actual string \xE6\x82\xA0, simply replace the double quotes with single quotes. Strings in single quotes are not parsed for escape sequences.
<?php echo '\xE6\x82\xA0'; ?>
Try escaping your slashes.
<?php echo "\\xE6\\x82\\xA0"; ?>
or simply use single quotes instead of double quotes
<?php echo '\xE6\x82\xA0'; ?>
or you can simply output directly
?>\xE6\x82\xA0<?php
Escape the slash characters.
<?php echo "\\xE6\\x82\\xA0"; ?>
Or write the string directly in template mode.
?>\xE6\x82\xA0<?php