FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » pass variable in php construct
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: pass variable in php construct [message #172184 is a reply to message #172175] Thu, 03 February 2011 13:54 Go to previous messageGo to previous message
sheldonlg is currently offline  sheldonlg
Messages: 166
Registered: September 2010
Karma:
Senior Member
On 2/3/2011 12:04 AM, Jerry Stuckle wrote:
> On 2/2/2011 11:27 PM, Joe wrote:
>> I have these simple lines in my php script:
>>
>> <?php
>> if (!empty($_GET[req])) {
>> print "<h2>$_GET[req]</h2>";
>> ?>
>> <h3>"$_GET[req]"</h3>
>> <?php
>> } else {
>> ...
>> }
>> ?>
>>
>> I wonder why the $_GET[req] value shows up within the php code block
>> (print to<h2> tags), but not showing up in the html block (between
>> <h3> tags)? Is it suppose so or I missed something? (I tried to pass
>> it to a local defined variable but still cannot be used in 'html'
>> block).
>>
>> Thanks in advance,
>> joe
>
> First thing is to turn on all errors and notices on your development
> system (you DO have a development system, don't you?)
>
> This will give you an E_NOTICE on the line
>
> print "<h2>$_GET[req]</h2>"
>
>

If you wanted your line to get the $_GET then you needed to do:

<h3><?php print $_GET['foo']; ?></h3>

or simply moved your firs ?> to after the <h3> stuff and use another print.

PHP _ONLY_ does PHP stuff inside <?php ..... ?>. Outside those blocks
it is simply text like any other text.

--
Shelly
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Help with my website
Next Topic: validating / converting time for insertion into mysql DB??
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 13:38:26 GMT 2024

Total time taken to generate the page: 0.06348 seconds