New to PHP and changed some code further down than line 1 on a WordPress site. Using Dreamweaver CC to upload. Getting:
Parse error: syntax error, unexpected T_IF in /home/jodyrein/public_html/www.writersblogfinder.com/wp-content/themes/rockthebook/functions.php on line 1
at www.writersblogfinder.com
Here is the first few lines of code:
<?php
/**
* rockthebook functions and definitions
*
* @package rockthebook
*/
/**
* Set the content width based on the theme's design and stylesheet.
*/
if ( ! isset( $content_width ) )
$content_width = 640; /* pixels */
Check that you have not edited your file using a horrible editor, like notepad. Your if() statement is reported as line 1, prrobably because of the lineends. Save the file in another editor, that uses newline instead or carriage return.
I've had similar problems before with hidden/non standard characters creeping into the file thanks to bugs / quirks in the editor. Best thing to do - copy the whole lot of the code into something like notepad (PC) or textmate (mac) and save the file out again, re-upload and re-test it... usually resolves it for me.
Seems Dreamweaver was loading the php text all as one line. I pasted the php into the Wordpress editor and and it's fine
I just wanted to mention after hours of trying to figure this out, re-saving from Notepad worked!
I use Sublime Text 3 as my daily text editor, so I find it quite odd that this issue wasn't being picked up, but copying the code from ST3, pasting in to Notepad and then saving over functions.php fixed the error.
I should also note that I was only seeing this error on the server, not on my localhost.
Thank you for this advice!
copying to Notepad editor saving and uploading fixed my problem.