PHP Parse error:  parse error, unexpected T_STRING in

Posted on 2009-04-21
Last Modified: 2013-12-13
PHP Parse error:  parse error, unexpected T_STRING in abc.php  on line 2:
I'm getting this on Linux environment but the same script works on Windows box.

Anything wrong?

the contents of the abc.php is as follows:

<?php header('Content-type: text/xml'); ?>

<?xml version="1.0" encoding="utf-8" ?>



include 'config.php';

$con = mysql_connect($dbhost, $dbuser, $dbpass);

if (!$con)


  die('Could not connect: ' . mysql_error());







Open in new window

Question by:SimonHowald
    LVL 8

    Accepted Solution

    Try changing:
    <?xml version="1.0" encoding="utf-8" ?>
    <? echo "<?xml version='1.0' encoding='utf-8' ?>"; ?>

    Open in new window


    Author Comment

    Thanks it worked. One more question before I close this chain...
    why do we need to do this?

    Author Closing Comment

    you are PHP Genius!
    LVL 8

    Expert Comment

    The XML headers use "<?" and "?>" ...just like PHP ;)

    PHP didn't know how to handle "xml version..." so you had to echo it.

    Hope that helps!

    Author Comment


    Featured Post

    Easy Project Management (No User Manual Required)

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now