Reputation: 11
I have a weird problem, in my code when I try to include another file, it doesn't recognize it because the ">" symbol in any part of my code. I'm running my code in an Ubuntu server with lamp. The problem is just in the new server, i have already running my code in other servers and never got this kind of error.
This is my example code, just include another file in test.php
<?php
//these 2 lines are just for output reference doesn´t affect the code
echo "Existe :: ". file_exists("Connection2.php")."<p>"; // Output :: Existe 1
echo "Es leible ::" . is_readable("Connection2.php")."<p>"; //Output :: Existe 1
include_once 'Connection2.php';
?>
The Connection2.php files is in the same directory and the code is:
<?php
/**
* Los parametros de conexión se encuentran en el archivo
dbCredentials.php en lib > db
* Podemos mandar conexiones personalizadas llenando los parámetros opcionales
* @author pitler
*/
class Connection2
{
public $connection;
/**
* Nombre de la clase
* @var String Nombre de la clase
*/
private $className;
function __construct()
{
$this->className = "Connection2";
}
}
?>
When I run test.php I don't have an error, it just includes the content of the file but after the ">" sign in the comment block where it says : lib > db and the output is ::
Existe :: 1
Es leible ::1
db * Podemos mandar conexiones personalizadas llenando los parámetros opcionales * @author pitler */ class Connection2 { public $connection; /** * Nombre de la clase * @var String Nombre de la clase */ private $className; function __construct() { $this->className = "Connection2"; } } ?>
The file exists and is readable. As you can see, it just includes all the text of my Connection2.php file after the ">" sign in the comments block.
If I take out the ">" symbol of my comments block, the results is ::
Existe :: 1
Es leible ::1
className = "Connection2"; } } ?>
As you can see, now it gets the content of Connection.php but after it finds the ">" that is when i assign the variable $this->className = "Connection2";
, the result is the text after that.
Any suggestions ????
Upvotes: 0
Views: 103
Reputation: 11
The problem was that i made changes to the configuration files of the bitnami package in the ubuntu server, so i restarted apache many times but never the php service, so i did it with this command
sudo /opt/bitnami/ctlscript.sh restart php-fpm
and it works, i dont know wich configuration files failed but nevermind, now it works.. :)
Upvotes: 1
Reputation: 239270
You're missing opening <?php
tags in all of your files.
If you don't have an opening <?php
tag, the entire file is assumed to be in HTML context. Everything in the file will be dumped to the browser.
Upvotes: 4