FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Disabling "This is a string with a $var"?





Stubru Freak
So basically, php will change this to:
"This is a string with a value of a variable"

Some people seem to like this, although to me, you quote strings to make clear they are not variables.
Almost all languages do this (because most languages don't add a special sign before variable names) and I don't like doing something really different in different languages, so I never use this function.

Is there any way to turn this off?
(I mean a php.ini directive or something, NOT hacking the source code)

Thanks,
Frederik Vanderstraeten
eepman
Isnt it just use single quotes instead of doubles. ' as opposed to " to encompass the string literal. I always use '.
Stubru Freak
eepman wrote:
Isnt it just use single quotes instead of doubles. ' as opposed to " to encompass the string literal. I always use '.


Yes I know, but I have some strange attraction to using double quotes :p
Just want to know if there's an easy way to turn it off instead of changing my whole coding style.
One of the reasons I use double quotes is because you need double quotes for SQL queries too, for example (or escape each single quote in the query)
eepman
For me i just don't care, if i have to use esc chars i will and if i have to use double quotes i will and if i dont i wont. But i usually just use ' and concatenate the vars on. multiple literals and multible vars, but it works.

I still dont think you can do that sorry Sad
Rhysige
if you REALLY want to... you would need to edit php.ini I think. Dont ask how I dont know but I suggest the simpler solution is change your coding style. I never use " at all. I use ' and when I need to add a variable '. like
echo 'strin here '. $variable .' more string';
snowboardalliance
eepman wrote:
For me i just don't care, if i have to use esc chars i will and if i have to use double quotes i will and if i dont i wont. But i usually just use ' and concatenate the vars on. multiple literals and multible vars, but it works.

I still dont think you can do that sorry Sad


YEah, single quotes are better but you just need double quotes for like \n and stuff.
Stubru Freak
Rhysige wrote:
if you REALLY want to... you would need to edit php.ini I think. Dont ask how I dont know but I suggest the simpler solution is change your coding style. I never use " at all. I use ' and when I need to add a variable '. like
echo 'strin here '. $variable .' more string';


Editing php.ini would not be a problem


Does anyone know the name of this by the way?
Atomo64
There's no such setting, just use ' instead of "
Kefka
Getting used to use single quotes instead of double quotes is better, since you may have to use another server in the future, with default configurations...
n0obie4life
Code:
<?php echo "Hello, this is my variable"; ?>$variable<?php echo "lol!";?>


Put the $variable word outside the ?> Smile
JayBee
I don't know, why you don't like this pretty functionality? Wink
The one of easiest solutions is to escape the $, but I suppose you
Code:
"know that \$var=$var";
Related topics
fatal error in Joomla installation "index.php"
Delphi problem! (Language is Pascal)
Reducing Exploits
replace a string for a position of text
Javascript: Multiply string with number
Fantastico could be updated
[java scripts] Text effect , img ....
PHP Validation Class
Tutorial: Image Rollovers w/ Javascript
Why You Should Never Use Flash
Search function
A ActionScript,showing a running date.
writing COM components in Perl
An Example to mySQL class
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.