Does PHP offer any special quoting mechanisms (we're not talking about magic_quotes or addslashes or things like that).
For example, I have absolutely no understanding as to why the following returns a parse error:
$array['key'] = 'value';
echo "$array['key']";
While from the sample, you might say to just use:
echo $array['key'];
It becomes a problem when your working with a 50 part for in php and are writing such as:
echo "<input type='text' name='email' value='" . $INPUT['email'] . "'>";
While from that sample, you might say to just use:
echo "<input type='text' name='email' value='$email'>";
which would be fine if this was in the core code block of a given page, however, I'm working with a very complex system that spans more then 100 files containing php and more then 40 included "library files" and so rather then having to declare 50 variables as globals at the beginning of every routine, during the loading of one of our common libraries, we parse $QUERY_STRING and $HTTP_POST_VARS so that they all end up in $INPUT and then we can bring the entire input in to any function by simply declaring $INPUT as a global.
So, I have two very specific questions in this.
First, are there any alternatives to ending a quoted string and then concatenating in the array element and then concatenating back into a quoted string (any way to use say $INPUT['email'] directly inside of a quoted area?).
Second, are there any alternative quoting mechanisms as a whole so that quoting can be used freely within a quoted string, for example, in perl, I can do:
$html = qq<input type="text" name="email" value=$input{'email'};
By using qq rather then ", I end up with a interpolated string that is delimited (start and end) by the character following qq (in this case ) and I can freely use both single and double quotes within the quoted string without any problems.
I might add of course that even the original example would work fine in perl:
print "<input type='text' name='email' value='$input{'email'}'>";
Sorry for the long explanation. I just wanted to be clear on my objectives and why I'm seeking to do what I'm trying to do. I'm a die hard perl coder and while initially php offers some promises of cutting my development time down and greater portability and easier deployment for end users, it is small quirks like the fact that I've yet to find an alternate quoting mechnism and worse yet, small quirks like the fact that you can't call an associative array element within any quoting (i.e. echo "$INPUT['email']"😉 which are making PHP life difficult 🙁
Scott A. Hammond, Sr., CEO
Prima Internet, Inc.