On Jan 27, 2007, at 10:26 AM, Felix Geisendörfer wrote:

>> Any idea why this is considered bad practice?
> Yes. Their are several things I can think of right away:
>
> People often mix double & single quotes in one project: using  
> inline variables can easily cause bugs if the programmer doesn't  
> remember that they won't work inside his single quoted strings
> When looking at a large piece of PHP code, inline variables are  
> harder to spot and some less advanced syntax highlighters don't  
> recognize them -> Readability
> Consistency: If you use single & double quotes then not using  
> inline variables will make for a more consistent code base
> Function wrapping: When using inline variables, you can't wrap them  
> with a function call. So this makes it more work to add those calls  
> later on, which often causes lazy developers to skip data  
> sanitation (big issue with XSS attacks)
> Those are the reasons that just came to my head, but I'm sure there  
> are a couple others as well.

Another one I can think of is that inline variables can't handle  
object references

<?php
class TestClass {
         var $property;

         function TestClass() {
                 $this->property = new StdClass;
                 $this->property->value =  "what's up pussycat";
         }
         function method(){
                 return "hello world";
         }
}
$object = new TestClass;

# this will not work right
print "property=$object->property->value and method yields $object- 
 >method()\n";
# this will
printf("property=%s and method yields %s\n",$object->property->value, 
$object->method());

?>

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to