Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

<? vs <?php - PHP in html

  • 31-05-2009 5:12pm
    #1
    Registered Users, Registered Users 2 Posts: 1,086 ✭✭✭


    I have installed EasyPHP 3.0 on localhost on my computer. When I try to get a simple html page with the following script working it does not work.
    <title><? echo "This is the title"; ?></title>
    

    This just sets the title as "<? echo "This is the title"; ?>". However when I use the following code it works fine and does not show the php open and close code.
    <title><?[B]php[/B] echo "This is the title"; ?></title>
    

    I find it annoying to have to write "<?php" every time I open my php code in my html. Any idea how to change the settings so "<?" would be sufficient?

    For all my previous PHP programming I have found "<?" sufficient.


Comments

  • Registered Users, Registered Users 2 Posts: 7,518 ✭✭✭matrim


    <? is the short tag way of opening the php part of the scripts.

    I think there is an option the your php.ini file to allow them.

    It's probably best practice to use <?php as some hosting providers may not support <?

    Also if you are using short tags you can do a quick echo by using

    <?= "This is the title" ?>


  • Moderators, Education Moderators, Home & Garden Moderators Posts: 8,259 Mod ✭✭✭✭Jonathan


    http://ie.php.net/manual/en/ini.core.php



    If you don't have access to php.ini you could try putting something like
    php_flag short_open_tag 1
    
    in the root .htaccess file.


  • Closed Accounts Posts: 25,848 ✭✭✭✭Zombrex


    Peter B wrote: »
    For all my previous PHP programming I have found "<?" sufficient.

    <? is generally considered bad practice (more mistakes, harder to debug, conflicts with other scripts etc).

    Might be fine for developing on your local machine but you will find hosting providers have this short cut turned off to avoid the problems with it. I've never developed PHP where we used short tags and some places I worked you weren't allowed.

    Best is to try and unlearn <? and stick with <?php

    If you really must use it then as the rest say it is controlled in your php.ini file under short_tags directive.


Advertisement