Title: Parse Error: Syntax Error when index.php copied to root
Last modified: August 21, 2016

---

# Parse Error: Syntax Error when index.php copied to root

 *  Resolved [SomethingWonderful](https://wordpress.org/support/users/somethingwonderful/)
 * (@somethingwonderful)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/)
 * I’m having a nightmare.
 * When I copy the index.php file (and the htaccess) to the root directory I’m getting
   the error message below?
 * “”Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in /home/*****/
   public_html/index.php on line 17″”
 * I’ve created many wordpress sites and never come across this problem before. 
   It’s happening on every new install.
 * No plug-ins, no custom themes, happens on the cleanest new installation. My hosting
   company also have no idea what could be causing the problem.
 * Has anyone else had this problem, or can anyone enlighten me with suggestions?
 * Many thanks,
 * SW

Viewing 15 replies - 1 through 15 (of 27 total)

1 [2](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/page/2/?output_format=md)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343020)
 * What is in this index.php file?
 *  Thread Starter [SomethingWonderful](https://wordpress.org/support/users/somethingwonderful/)
 * (@somethingwonderful)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343022)
 * It’s the standard wordpress index file that loads the wp-blog-header.php…
 * That’s what is so odd..
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343029)
 * Can we see it?
 *  Thread Starter [SomethingWonderful](https://wordpress.org/support/users/somethingwonderful/)
 * (@somethingwonderful)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343030)
 * /**
    * Front to the WordPress application. This file doesn’t do anything, but
   loads * wp-blog-header.php which does and tells WordPress to load the theme. **
   [@package](https://wordpress.org/support/users/package/) WordPress */
 * /**
    * Tells WordPress to load the WordPress theme and output it. * * [@var](https://wordpress.org/support/users/var/)
   bool */ ‘define(‘WP_USE_THEMES’, true);
 * /** Loads the WordPress Environment and Template */
    require(‘./wp-blog-header.
   php’);’
 *  Thread Starter [SomethingWonderful](https://wordpress.org/support/users/somethingwonderful/)
 * (@somethingwonderful)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343031)
 * I’m adding the wordpress directory as below… But not calling it “wordpress” obv…
 * ‘define(‘WP_USE_THEMES’, true);
 * /** Loads the WordPress Environment and Template */
    require(‘./wordpress/wp-
   blog-header.php’);
 *  Thread Starter [SomethingWonderful](https://wordpress.org/support/users/somethingwonderful/)
 * (@somethingwonderful)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343032)
 * Actually apologies…
 * it’s the new wordpress index.php as below.
 *     ```
       <?php
       /**
        * Front to the WordPress application. This file doesn't do anything, but loads
        * wp-blog-header.php which does and tells WordPress to load the theme.
        *
        * @package WordPress
        */
   
       /**
        * Tells WordPress to load the WordPress theme and output it.
        *
        * @var bool
        */
       'define('WP_USE_THEMES', true);
   
       /** Loads the WordPress Environment and Template */
       require( dirname( __FILE__ ) . '/wp-blog-header.php' );
       ```
   
 * _[Moderator Note: Please post code & markup between backticks or use the code
   button. Your posted code may now have been permanently damaged by the forum’s
   parser.]_
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343036)
 * Did you add the single quotes here
 *     ```
       'define(... rest of code
       ```
   
 * and here:
 *     ```
       require(...);'
       ```
   
 *  Thread Starter [SomethingWonderful](https://wordpress.org/support/users/somethingwonderful/)
 * (@somethingwonderful)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343045)
 * Ahh no, just wanted to separate the code.
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343057)
 * Try:
 *     ```
       <?php
       /**
        * Front to the WordPress application. This file doesn't do anything, but loads
        * wp-blog-header.php which does and tells WordPress to load the theme.
        *
        * @package WordPress
        */
   
       /**
        * Tells WordPress to load the WordPress theme and output it.
        *
        * @var bool
        */
       define('WP_USE_THEMES', true);
   
       /** Loads the WordPress Environment and Template */
       require( dirname( __FILE__ ) . '/path_to_wordpress_here/wp-blog-header.php' );
       ```
   
 * substituting `path_to_wordpress_here` appropriately.
 *  Thread Starter [SomethingWonderful](https://wordpress.org/support/users/somethingwonderful/)
 * (@somethingwonderful)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343061)
 * Hi Esmi,
 * That’s no different to what I have been doing? My apologies but I used the older
   WP index.php in my first answer to you then corrected a couple of posts down.
 * I have spoken to one other person who had this problem, using a different hosting
   company to me. He couldn’t find an answer either. But I can’t believe we’re the
   only two?
 * The only solution for me at the moment is to install wordpress in the root directory
   but that really isn’t ideal…
 * SW
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343064)
 * > That’s no different to what I have been doing?
 * The code I gave was pulled from a working install, so it might be worth trying
   it in case your copy has non-visible characters at the end of the file.
 * > I can’t believe we’re the only two?
 * Sorry but I can. I’ve used this technique many times without any problems.
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343065)
 * What editor did you use?
    [http://codex.wordpress.org/Editing_Files#Using_Text_Editors](http://codex.wordpress.org/Editing_Files#Using_Text_Editors)
 *  Thread Starter [SomethingWonderful](https://wordpress.org/support/users/somethingwonderful/)
 * (@somethingwonderful)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343066)
 * Hi again Esmi,
 * Have tried copying the file directly from a working site, no luck. Have also 
   used Installatron to install WordPress files and DB and same problem.
 * I’ve also used exactly the same technique on over 100 WordPress sites in the 
   last 3 years.
 * I’m asking the hosting company to look into it but they are denying any issue
   their end. I think I’m going to have to go to a new host but that is such a nuisance.
 * So frustrating…
 * SW
 *  Thread Starter [SomethingWonderful](https://wordpress.org/support/users/somethingwonderful/)
 * (@somethingwonderful)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343069)
 * Hi keesiemeijer,
 * TextEditor on Mac, but like I say, I’ve tried copying the index file from other
   working sites to no avail.
 * I think it might have something to do with
 * require( dirname( __FILE__ ) . ‘/path_to_wordpress_here/wp-blog-header.php’ );
 * which has just changed in the new version from
 * require(‘./wordpress/wp-blog-header.php’);
 * Hence the message
 * T_ENCAPSED_AND_WHITESPACE
 * SW
 *  Moderator [keesiemeijer](https://wordpress.org/support/users/keesiemeijer/)
 * (@keesiemeijer)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/#post-4343075)
 * I don’t think that’s the problem. If the path was wrong you would get this error:
   failed to open stream: No such file or directory.
 * Not sure what’s going on here but I would download a fresh copy of WordPress 
   and edit the index.php with another texteditor (just for testing):
    [http://codex.wordpress.org/Editing_Files#Using_Text_Editors](http://codex.wordpress.org/Editing_Files#Using_Text_Editors)

Viewing 15 replies - 1 through 15 (of 27 total)

1 [2](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/page/2/?output_format=md)

The topic ‘Parse Error: Syntax Error when index.php copied to root’ is closed to
new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 27 replies
 * 14 participants
 * Last reply from: [Andrew Nevins](https://wordpress.org/support/users/anevins/)
 * Last activity: [11 years, 5 months ago](https://wordpress.org/support/topic/parse-error-syntax-error-when-indexphp-copied-to-root/page/2/#post-4343321)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
