Skaperen
Skaperen

Reputation: 463

<? and <?php both fail, what should work?

running php5.5.9 on apache2.4 under ubuntu 14.04.2 LTS server x86_64 my old php code has <? in the middle to switch from HTML back to php but it no longer works and the <? is just output as if it were HTML. if i change it to <?php then the whole page goes blank. curl shows in this case that the server outputs nothing. this is where i am trying to output the client IP address.

the web page: http://linuxhomepage.com/ or: http://linuxhomepage.com/index.php

you can see the raw php code here: http://linuxhomepage.com/index.txt

if you get an IPv6 address these won't work as apache is not letting me bind it, yet (i am still digging into that at a lower priority).

<? and <?php both fail in different ways. so how can i make this work?

Edit: IPv6 is working on Apache now, next to get DNS on IPv6.

Upvotes: 1

Views: 129

Answers (4)

jx12345
jx12345

Reputation: 1670

<? is probably failing because that's being deprecated.

<?php probably isn't failing but there's probably an error somewhere in your code and error reporting is turned off on your server, so you just get a blank screen.

To make sure this is the case try something simple like:

<?php 
    echo 'test';
?>

And make sure that works.

Upvotes: 4

DKSan
DKSan

Reputation: 4197

Please try deleting the part that is causing the problem.

As of your textfile it would be

<?
echo $_SERVER['REMOTE_ADDR']
?>

If it works without try adding

<?php echo "TEST"; ?>

If this also works you can replace "TEST" by $_SERVER['REMOTE_ADDR'] and see if it works.

Upvotes: 0

Peter
Peter

Reputation: 16923

the <? is just output as if it were HTML.

it's because short_tags are not recommend and disabled by default

PHP also allows for short open tag <? (which is discouraged since it is only available if enabled using the short_open_tag php.ini configuration file directive, or if PHP was configured with the --enable-short-tags option).

if i change it to <?php then the whole page goes blank.

it's probably because you have errors in your PHP page (especially if you run old code in new PHP version)

please enable error reporting - php.ini directives error_reporting and display_errors

Upvotes: 2

Albert Kozłowski
Albert Kozłowski

Reputation: 476

Simillar question: PHP 5.5 short_open_tag=on Security Hole?

You should change short open tag in your php ini to: short_open_tag=on

Upvotes: 2

Related Questions