Page 1 of 1

[SOLVED] - Inserting direct HTML in functions

Posted: Tue Aug 10, 2004 10:00 pm
by anjanesh
Do these really make a difference ?

Code: Select all

<?php
function Display1()
{
  ?>
  Hello<BR>
  <?
}
function Display2()
{
  ?>
  Hello<BR>
  <?php
}
function Display3()
{
  echo 'Hello<BR>';
}
?>
All 3 displays work on my machine but in the server Display2 doesn't show up. Gives some error and after removing php from the <?php it showed up alright.
I know this is a function and I wanted to know if direct insertion of HTML tags will do any harm when compared to echo ?
Thanks

Posted: Tue Aug 10, 2004 10:24 pm
by d3ad1ysp0rk
If I remember correctly, you can't exit php while in a function declaration. Although it may just apply to classes.. I believe it's both.

display3 is the correct way to go about doing it.

Posted: Tue Aug 10, 2004 10:29 pm
by hawleyjr
All 3 may work but LilpunkSkateR is corre t use display3. The other two will only cause you problems.

Posted: Tue Aug 10, 2004 10:42 pm
by anjanesh
Alright. I'll use echo for all the lines.
But then again

Code: Select all

echo 'Text $row["id"] Text'; is not working
echo "ext $row['id']  Text"; while this is
Are ' and " treated differently ?

Posted: Tue Aug 10, 2004 10:43 pm
by hawleyjr
Yes, and please use PHP tags. '' does not look for variables in a string where " " does.

Posted: Tue Aug 10, 2004 10:49 pm
by anjanesh
I changed all that because I was getting this error and it still shows up:
Parse error: parse error, unexpected $end in xxxxxxx\xxx.php on line 211

There is a ?> at end. Now only one because the first one was for <?php at the location of function defiition. I knew I had many of <? and ?> and so I converted them all the echo but the error still shows ! There are only 210 lines and errno is 211 !!!

Posted: Tue Aug 10, 2004 10:52 pm
by hawleyjr
Post t your code in PHP tags and we'll take a look at it. Your error typically means you are trying to access a variable where variables don't belong.

Posted: Tue Aug 10, 2004 11:01 pm
by anjanesh
The entire code is 200 lines. How can I show you the ones required. I jist moved the function to another file so now its a lot lesser but still...

Posted: Tue Aug 10, 2004 11:03 pm
by anjanesh
Guess its the function thats giving the error. Now its showing that filename - the one where I moved the fn to

SOLVED - stupid mistake