|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Parse errors - Unexpected T_CONSTANT_ENCAPSED_STRING
Hello,
I am extremely new to coding in PHP and would appreciate if I could get some assistance on an error I'm receiving in one of my template files. I am getting this error: PHP Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in header_sgs.html on this code: <?php include '\template\navbar.html'; $fullPath = explode('/', $_SERVER['PHP_SELF']); echo "The foldername $fullPath[0]"; echo "The filename $fullPath[1]"; if (file_exists('\template\'.$fullPath[1].'.html')) { include 'c:\inetpub\webroot\soa\template\'.$fullPath[1].'.html'; } else if (file_exists('\template\'.$fullPath[2].'.html')) { include 'c:\inetpub\webroot\soa\template\'.$fullPath[2].'.html'; }else{ echo "<ul id=\"secondaryNav\" ></ul>"; } ?> <div id="page"> <!-- BEGIN PAGE CONTENT --> <?php if (file_exists("\Images\".$fullPath[1].".gif")) { echo "<img src="\Images\".$fullPath[1].".gif\" alt=\"".$fullPath[1]."\" />"; }else if (file_exists('\Images\'.$fullPath[1].'.jpg')) { echo "<img src="\Images\".$fullPath[1].".jpg\" alt=\"".$fullPath[1]."\" />"; } ?> It says it's failing on the first "if(file_exists...)" piece, but unfortunately, I'm too new to this to understand why it's failing. Help would be greatly appreciated! Cheers, Sheel Shah |
|
#2
|
||||
|
||||
|
syntax
Hi sheel331, welcome to the forums
It's easy to get lost when escaping and concatenating. PHP considers text that's not in quotes to be PHP code, Variables start with $, constants don't. Take a close look at PHP Code:
I find it helpful to use whitespace in my code, Both for indentation and separation. eg. instead of PHP Code:
PHP Code:
BTW, if you put your code inside BBtags, the color syntax highlighting will help.
__________________
WP plugins - Error Reporting, Clean Options http://www.mittineague.com/dev/er.php http://www.mittineague.com/dev/co.php Last edited by Mittineague : March 24th, 2008 at 10:46 PM. Reason: added tip |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Parse errors - Unexpected T_CONSTANT_ENCAPSED_STRING |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|