News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

body tag...different. Cant add tables

Started by 1MileCrash, August 25, 2005, 08:53:31 PM

Previous topic - Next topic

1MileCrash

Ending the php session in the <head> got me
<?
echo"
</head>
<body>";


rather than the normal
</head>
<body>',

or whatever.

I think that's related to why this
<?
echo"
</head>
<body><table width="100%"><tr><td width="100%" class="top_image" height="15"></td></tr><tr><td width="100%" class="headerimg" height="43"></td></tr><tr><td width="100%">";

gives me a parse error, while this
</head>
<body><table width="100%"><tr><td width="100%" class="top_image" height="15"></td></tr><tr><td width="100%" class="headerimg" height="43"></td></tr><tr><td width="100%">',

doesnt..

So....why? And how can i fix it?
The only thing php can't do is tell you how much milk is left in the fridge.



[Unknown]

I'd really suggest avoiding using that.  <?php and ?> are nice, but they incur a penalty.  It's better just to use echo.

Anyway, remember... it's just like quotes!  This:

?>....<?php

They must match in pairs.  Another example:

?>Hi, how're you?  My name<?php if (false) { ?>(this won't ever be shown)<?php } ?> is Hector.<?php

But, really, it looks nicer - to me, at least - like this:

echo 'Hi, how\'re you?  My name';
if (false)
   echo '(this won\'t ever be shown)';
echo ' is Hector.';

They are equivalent, except the echo one might be a little faster, based on benchmarks.  In SMF, the ENTIRE FILE is in PHP by default.  It looks like this:

<?php

// ... the file here ... //

?>

Here are some examples:

Code (WRONG!) Select
echo 'Hi, my name is <?php echo 'Hector.';?>';
Code (WRONG!) Select
echo 'Hi, my name is ?>Hector.<?php
Code (Right.) Select
echo 'Hi, my name is '; ?>Hector.<?php
Code (Right.) Select
echo 'Hi, my name is Hector.';

In all cases, every PHP line must be valid.  If you want to leave the PHP part, you can - but make sure everything is fine and dandy first.

I suggest using a text editor, like ConTEXT, which highlights PHP code.  A higlighter can help you identify where you may have made a mistake.

-[Unknown]

1MileCrash

thanks again. Im still learning php.  :P. Ill get one of my friends to read over it and tell me what i can do differently/better.

Anyway, the problem dissapeared after putting \'s before all of the " in the table attributes.
The only thing php can't do is tell you how much milk is left in the fridge.



Advertisement: