• Sign in to Neowin Faster!

    Create an account on Neowin to contribute and support the site.

  • 0
Sign in to follow this  

[PHP] how to echo any text including brackets?

Question

Internet    0

Well i need to echo this exact text and keep the same formatting

e(72,0,0,"-",false,"nav9",

how can i store that in a variable without getting unexpected bracket errors when i try to echo it

Share this post


Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0
russellc    1

To echo:

echo 'e(72,0,0,"-",false,"nav9",';

To store in a variable:

$varName = 'e(72,0,0,"-",false,"nav9",';
echo $varName;

Share this post


Link to post
Share on other sites
  • 0
stereopixels    23

$variableName = 'e(72,0,0,"-",false,"nav9",'

Using single quotes around it should work.

Share this post


Link to post
Share on other sites
  • 0
FlibbyFlobby    0
Well i need to echo this exact text and keep the same formatting

e(72,0,0,"-",false,"nav9",

how can i store that in a variable without getting unexpected bracket errors when i try to echo it

Store it as a string:

$string = 'e(72,0,0,"-",false,"nav9",';
echo $string;

Share this post


Link to post
Share on other sites
  • 0
zivan56    22

echo <<<END

Whatever you want as long as line does not start with END and semicolon

END;

$test = <<<END

....

Also works.

Share this post


Link to post
Share on other sites
  • 0
ckgni    0

Yes, I use to do what ivanz said with <<<EOF

print &lt;&lt;&lt;EOF
e(72,0,0,"-",false,"nav9",
EOF;

It is necessary to have not any blank spaces after <<<EOF and before EOF; else you will get a parse error.

Another (but more difficult) way is to use escape character \

print "e(72,0,0,\"-\",false,\"nav9\",";

or (as already russelc said) you can use single quotes.

You can enclose double quotation marks within single quotation marks and vice versa.

Edited by ckgni

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.