Question about opening php code

Home Forums Languages PHP & MySQL Question about opening php code

Tagged: ,

This topic contains 1 reply, has 2 voices, and was last updated by  Vera 1 year, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #13911

    SailorDonut
    Participant

    I’ve noticed when I follow scripts and tutorials that sometimes the code will look like…

    First use of php code on the page: <?php

    and the rest of the page only uses <? when they reopen php

    Meanwhile, others I’ve seen use <?php every time they open a php code.

    It seems like it works the same either way, so I was wondering: Does it matter? Which is the more correct way? Will there be different results depending on what you use? Thanks!

    #14710

    Vera
    Participant

    Both are correct, actually. The second is called a short open tag, and can only work if it is enabled from php.ini (i.e. check that short_open_tag is On, as opposed to Off).

    Of course, when you’re being hosted you don’t generally have access to the php.ini file, so there’s nothing you can do to change this setting. As a precaution, it is recommended that you use the long form <?php … ?> which is guaranteed to always work.

    We also had a little debate about this topic here: http://girlswhogeek.com/forums/topic/wowzers-learning-curve

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.