Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a blade running SunOS 5.1 and PHP. There's a problem with it parsing PHP though, and once it hits a =>, such as setting up an array, it starts printing the source to the page.

Example source:

<?php

$tmpVar = 'just testing';
$tmpArray = array(
    'test1' => 'rawr1',
    'test2' => 'rawr2',
    'test3' => 'rawr3'
);

echo "Testing<br/>";    

?>

This would output:

'rawr1', 'test2' => 'rawr2', 'test3' => 'rawr3'); echo "Testing<br/>"; ?>
share|improve this question
    
It would be helpful if you mentioned what webserver you are running, what handlers are assigned to PHP files and how the PHP interpreter is invoked by the webserver. –  symcbean Jan 28 '11 at 12:22
    
I'm not the server admin, so I really don't know. I was hoping this would be a generic enough issue for it to be easy to diagnose without that. All I know is that the system is SunOS 5.1, and it's running Apache 2.2 as the Server API. –  Atrox Jan 28 '11 at 12:30
    
The output really doesnt make sence to me, seems it is just a part of it. It seems PHP is not parser anyway to me, please write and execute script <?php phpinfo(); ?>, can you see php information on page? –  Ency Jan 28 '11 at 13:20

4 Answers 4

up vote 0 down vote accepted

Either your version of PHP doesn't recognize the <?php tag (try with <? instead?), or more likely the PHP interpreter is not working/started/triggered.

Thus, when loaded the PHP code is interpreted as if it were HTML,

  <?php $tmpVar = 'just testing'; $tmpArray = array('test1' =>

the line above starts with < and ends with >, thus the browser considers it to be a tag, and it is not displayed.

Then the rest is displayed normally...

 'rawr1','test2' => 'rawr2','test3' => 'rawr3'); echo "Testing<br/>"; 

Try with <?, but more likely your have a PHP configuration problem.

share|improve this answer
    
Actually the support for <? is optional while <?php is not, so I guess that's not the problem. –  lapo Jan 28 '11 at 14:15
    
We don't know much about his configuration - but as I said it is more likely to be a server configuration problem (PHP not triggered/started) –  ring0 Jan 28 '11 at 14:17

As Ency said, are you sure it is parsing PHP at all? It doesn't look like it. It's probably just dumping the entire code and your browser is interpreting it as HTML, seeing the whole thing as one giant tag from <?php to the first > it encounters.

Do the <?php phpinfo(); ?> test.

Also, are you sure the filename is correct? That it actually is called something like index.php, not index.html or index.php.txt or whatever.

From the looks of it, it seems likely PHP has not been enabled at all. Contact the server administrator.

share|improve this answer

What's the file extension of your script file? Is that extension setup to be parsed by PHP? The extension usually should be .php. The output snippet looks like you are using .html instead.

share|improve this answer

Are you sure that PHP is actually installed? If it is, are you sure that Apache is configured correctly to use PHP?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.