Originally posted by vaska
for some reason i was under the impression that i couldn't use "echo" inside of slashes like...
nor do i need the <? or ?>...this is what i have...and it doesn't work...
<input type=\"hidden\" name=\"cdate\" value=\"<? echo strftime(\"%m.%d.%Y\" ,time()) ?>\">
need some advice please...jv
The problem is, you are escaping the " marks in your HTML and you are
embedding PHP in there. Also you are escaping " both in PHP and out of PHP.
First, when you are in a PHP construct, then everything must be echoed.
If you drop out of PHP construct, then you can put normal HTML.
This:
<?php
echo "hello there\n";
echo "<font face=\"Arial\" size=\"10\"><b><br>\n";
echo "I was talking to ".$tom." the other day.<br>\n";
?>
is equivalent to this:
hello there
<font face="Arial" size="10"<b><br>
I was talking to <? echo $tom; ?> the other day.<br>
When echoing/printing, you need to escape " marks. When issuing a PHP command,
you don't escape " marks. I know it is confusing at first.
For instance:
echo "elvis was \"here\".";
Not:
echo \"elvis was \"here\".\";
As for your solution,
EITHER (inside a PHP construct):
echo "<input type=\"hidden\" name=\"cdate\" value=\"".strftime("%m.%d.%Y" ,time())."\">";
OR (outside a PHP construct):
<input type="hidden" name="cdate" value="<? echo strftime("%m.%d.%Y" ,time()); ?>">