NOTE:
This question is NOT about using short tags in PHP. The issue is not the short tags themselves but the way thatinclude
functions seem to ignore the disabled status of short tags on this Plesk server.
I have a new site to take care of and fix up. The site was built by another, and was built many years ago using non-best practise. The site has recently been moved to a Plesk Server.
I am unfamiliar with Plesk and so have been learning it's routines.
A core setting on the Plesk PHP setup is that short tags ( <? ... ?>
) are disabled. The site I'm working on makes extensive use of short tags (as well as full <?php
tags).
The issue is the code within the short tags the PHP include
function still executes and loads, and its contents still outputs to the browser source HTML, but anything else in the short tags does not execute.
include
?short_open_tag: Off
The HTML Page (index.php
, various pages):
<?
session_start();
include "inc/dbi.php";
if(isset($_REQUEST['id'])){
$id = substr($_REQUEST['id'],0,6);
}
else{
header("Location: index.php?msg=No image specified");
exit;
}
$qry = mysqli_query($MySQlink,"...");
$row = mysqli_fetch_array($qry);
$docwidth = floor($row['width']*4.26);
$docwidth /= 100;
$docheight = floor($row['height']*04.26);
$docheight /= 100;
$descr = nl2br($descr);
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
...
...
The inc/dbi.php page:
<?php
$user = "some_user";
$pass = "some_pass";
$db = "some_db";
$MySQlink = mysqli_connect( "localhost" , $user, $pass, $db );
if ( ! $MySQlink ) { mysqli_close($MySQlink); }
$now = date('Y-m-d H:i:s');
$today = date('Y-m-d ');
<?
session_start();
include "inc/dbi.php";
if(isset($_REQUEST['id'])){
$id = substr($_REQUEST['id'],0,6);
}
else{
header("Location: index.php?msg=No image specified");
exit;
}
$qry = mysqli_query($MySQlink,"...");
$row = mysqli_fetch_array($qry);
$docwidth = floor($row['width']*4.26);
$docwidth /= 100;
$docheight = floor($row['height']*04.26);
$docheight /= 100;
$descr = nl2br($descr);
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<?
session_start();
$user = "some_user";
$pass = "some_pass";
$db = "some_db";
$MySQlink = mysqli_connect( "localhost" , $user, $pass, $db );
if ( ! $MySQlink ) { mysqli_close($MySQlink); }
$now = date('Y-m-d H:i:s');
$today = date('Y-m-d ');
if(isset($_REQUEST['id'])){
$id = substr($_REQUEST['id'],0,6);
}
else{
header("Location: index.php?msg=No image specified");
exit;
}
$qry = mysqli_query($MySQlink,"...");
$row = mysqli_fetch_array($qry);
$docwidth = floor($row['width']*4.26);
$docwidth /= 100;
$docheight = floor($row['height']*04.26);
$docheight /= 100;
$descr = nl2br($descr);
?>
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
I am well aware of the short-coming of the above code, but it's not my work and it is my job to fix these shortcomings and make it [much] better.
But, I am confused by the behaviour of the include function, and have already read various PHP bug reports as well as reading up the manual for include
and PHP.ini short tags. none of which mentions this issue.
My chief concern is that for some period of time Database connection details were output to the HTML (and have since been changed, obviously).
The included files are not read on the compilation phase but during runtime.
Since your PHP interpreter doesn't interpret the code in short tags and dumps it directly to the browser, it is not guilty for replacing the include
statements with the content of the included files.
There is no php.ini
setting that could persuade it to behave like this.
I can imagine other causes:
include/require
statements with the content of the included files;The purpose of such a processing is to optimize the script by minimizing its disk access.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With