Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Programming»PHP»How to Enable Short Open Tag in PHP

    How to Enable Short Open Tag in PHP

    By RahulNovember 24, 20222 Mins Read

    Short open tags are a type of PHP code that allows you to use abbreviated syntax. This means you can omit the full <?php tag and instead use <?. This can save you a lot of time and effort, especially if you’re writing long PHP code blocks. Short open tags are not enabled by default in PHP, but you can easily enable them by adding a line of code to your php.ini file. Just open the file in a text editor and add the following line: “short_open_tag = On”. Once you’ve saved the file, restart your web server and you’ll be able to use short open tags in your PHP code.

    Advertisement

    Enable Short Tags in PHP

    Enabling short open tags is easy to do in most cases. First, open your php.ini file in a text editor. Then, look for the line that says “short_open_tag = Off” and change it to “short_open_tag = On”. Save the file and restart your web server, and you should be good to go!

     short_open_tag = On
    

    enable short open tag php

    After making the above changes restart the Apache service.

    Verify Short Tags in On

    To verify that the short tags are enabled in the PHP configuration. Create a PHP script with the short open tags and access in a web browser or execute from the command line. For example, I have created check.php with the following content.

    1
    2
    3
    <?
    echo "It's Working!";
    ?>

    Now execute this script using the command line or access file in a web browser.

    php check.php
    

    You should see the following result if the short tag is On:

    It's Working!
    

    If you can’t find the short_open_tag setting in your php.ini file, or if changing it doesn’t seem to have any effect, it’s possible that your server doesn’t support short open tags. In this case, you’ll need to use ?php instead of ? in your code.

    PHP short tag short_open_tag
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    Installing PHP on Pop!_OS

    How to Install PHP 8.x on Pop!_OS

    Managing Dependencies with Composer: A Beginner’s Guide

    10 Simple Ways to Speed Up Your WordPress Website

    10 Simple Ways to Speed Up Your WordPress Website

    View 2 Comments

    2 Comments

    1. Alexander on August 22, 2018 8:14 pm

      important! string number in config file is near 212

      Reply
    2. azarwp on November 5, 2017 3:55 pm

      thank you

      Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • How to Split Large Archives in Linux using the Command Line
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.