Christopher Bergin Posted February 9, 2013 Share Posted February 9, 2013 I've been trying to complete the exercise in Chapter 6 pertaining to namespaces.(scripts 6.9, 6.10) When attempting to run the script, I initially received an error like this: Warning: Unexpected character in input: '\' (ASCII=92) state=1; I even tried running the author's scripts and received the same error. After looking on the PHP site for more information, I tried deleting the initial '\' to the first object instantiation at the line number where the error specified: $hr = new MyNamespace\Company\Department('Accounting'); This resulted in a blank page. Further tinkering around resulted in an Internal Server Error. Since I'm using a hosting service, I've sent them an inquiry for directions to access the server log. In the meantime, I was wondering if anyone could shed light on this issue. The directory was configured as the book suggested. The version of PHP that I'm using is 5.3. Link to comment Share on other sites More sharing options...
Antonio Conte Posted February 10, 2013 Share Posted February 10, 2013 Are you sure you are on PHP 5.3? A small search teaches me that this error is common when Namespaces are not supported. Try printing out the version information to confirm what your host tells you: <?php echo 'Current PHP version: ' . phpversion(); ?> 2 Link to comment Share on other sites More sharing options...
Christopher Bergin Posted February 10, 2013 Author Share Posted February 10, 2013 yes, version 5.3.13. It's not important. I just thought I'd put it out there. I was able to recover the cgiErrorlog so I'll examine that. Link to comment Share on other sites More sharing options...
Antonio Conte Posted February 10, 2013 Share Posted February 10, 2013 It matters a bit. Namespace support was added in 5.3, so at least that's not the problem. Since you got a blank page, try adding these lines to the top of your file: <?php // Display errors ini_set('display_errors', 1); // Full error reporting error_reporting(-1); ?> Do you get any more information now? 2 Link to comment Share on other sites More sharing options...
Christopher Bergin Posted February 11, 2013 Author Share Posted February 11, 2013 thank-you Antonio, your error script pointed me to an incorrect directory setting in my include file. Everything works now. I'm going to hold on to that little nugget of code. Link to comment Share on other sites More sharing options...
Antonio Conte Posted February 12, 2013 Share Posted February 12, 2013 Glad you solved it. Link to comment Share on other sites More sharing options...
Recommended Posts