Jump to content
MakeWebGames

PHP - Open & Close Pages


Danny696

Recommended Posts

So, the very begginning of php right here.

There are 4 different ways to start a PHP file.

The first and most common way is <?php.

The second way and second most popular way to start a file, is simply <?. How simple right! Yet, this second version causes problems, as some servers do not allow the short tag.

The third and oldest would be this: <script language="php">.

The last way to open a PHP page is the same as Microsoft's ASP.NET script; like so: <%.

Offcourse, you only ever need to use one of these. I would suggest useing <?php. Simply becaise all severs can handle it and its up to date.

Ok, now you know how to start a file, how do we end it?

Well, for the first two opening tags (<?php & <?) its the same closing tag. This tag is simple; ?>.

For the third opening tag, we use another HTML tag: </script>.

The last tag is just like the first closing tag. Except this one uses a % instead of a ? So this tag is: %>.

Now, you can 'mix & match these opening and closing tags, for example, this next part will work: (although the forum doesnt highlight them correctly)

<script language="php">
echo'Something';
?>

And,

<?php
echo'Something';
%>

will work also.

Link to comment
Share on other sites

Don;t encourage people to use the WRONG way please.

It's . Stick to the standards.

While it may not be the best way, it work's. It may be better for someone to use that then the standard way, So let's not put it down eh,

 

I agree with what you are saying, however it works, most will use the standard way, however Danny was just informing them of other ways which as said in the topic "OLD"

 

Just because it works doesn't make it right,

It doesn't make it right however it does work and thats what counts at the end of it really
Link to comment
Share on other sites

  • 5 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...