Danny696 Posted November 6, 2010 Share Posted November 6, 2010 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. Quote Link to comment Share on other sites More sharing options...
Jordan Palmer Posted November 6, 2010 Share Posted November 6, 2010 While this is a simple task for most, It can be quite daunting for the new devs around, I am glad you've shared it with us.. After all the main thing for web developing is that you find your own way :) Very good post and informative tutorial Quote Link to comment Share on other sites More sharing options...
Spudinski Posted November 6, 2010 Share Posted November 6, 2010 Don;t encourage people to use the WRONG way please. It's <?php and ?>. Stick to the standards. 1 Quote Link to comment Share on other sites More sharing options...
Danny696 Posted November 6, 2010 Author Share Posted November 6, 2010 Umm, all of them ways are right, sure, the <script is old, but it will still work. Therefore, making all of the ways right, and your statement wrong. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted November 7, 2010 Share Posted November 7, 2010 Just because it works doesn't make it right, Quote Link to comment Share on other sites More sharing options...
Jordan Palmer Posted November 7, 2010 Share Posted November 7, 2010 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 Quote Link to comment Share on other sites More sharing options...
Spudinski Posted November 7, 2010 Share Posted November 7, 2010 The reason why these are even supported still is plainly for compatibility. The reason why the <script> tag works, is because before we all had PHP 3, PHP was known as Personal Home Page and it worked through the script tag. And FYI, it's not <script type> it is <script language>. Quote Link to comment Share on other sites More sharing options...
Rory_M Posted April 28, 2011 Share Posted April 28, 2011 <?php (start) ?> (end) this is simply the best for me, but thats is just my opion :) Quote Link to comment Share on other sites More sharing options...
Danny696 Posted April 28, 2011 Author Share Posted April 28, 2011 Rory_M, May I ask what on earth are you doing, this topic was dead, and thats where it belongs. No need to post, and its a useless post. Quote Link to comment Share on other sites More sharing options...
Rory_M Posted April 29, 2011 Share Posted April 29, 2011 oh right i didn't realize sorry. :) Quote Link to comment Share on other sites More sharing options...
Djkanna Posted April 29, 2011 Share Posted April 29, 2011 <?php (start) ?> (end) this is simply the best for me, but thats is just my opion :) It's the best method for most people. (: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.