This will occur because it is not including the other file and precisely because it is hiding the error message makes it difficult to know the reason for the problem. Avoid using @
, actually never use, much less if it is in a development phase, after all if something is developing that is hiding the error message, they are there to help you ?! I recommend you read publication on this subject.
When you do:
@Chat_Scripts;
You remove the Notice: Use of undefined constant Chat_Scripts - assumed 'Chat_Scripts' in /in/meLso on line 3'
, this occurs twice. So it gives echo
of Chat_Scripts
, because it assumes it would be echo 'Chat_Scripts'
.
Removing the error message does not correct the error, putting @
is not the solution. What happens is that constant can not be accessed, as said in the message, to solve you must use include()
between files or put all the information in a single file, so just join the two pieces of code you have in one.
For example:
C:.
├───inc
│ chat.php
│
└───public_html
index.php
There are two folders in the hierarchy shown above, each folder with a different file.
The C:/servidor/inc/
chat.php
will have:
const CHAT_ENABLE = 1;
const CHAT_HTML = [
1 => '<embed src="http://www.xatech.com/web_gear/chat/chat.swf"quality="high" width= "500" height= "300" name= "chat" FlashVars="id=158331371&rl=Brazilian" align="middle" allowscriptaccess= "sameDomain" type= "application/x-shockwave-flash" pluginspage= "http://xat.com/update_flash.shtml" /></embed>',
0 => '<div class="info-box"> O Chat se encontra Desativado</div>'
];
The C:/servidor/public_html/
index.php
has:
include('../inc/chat');
echo CHAT_HTML[ CHAT_ENABLE ];
The
include
will include the
chat.php
file, so there will be
CHAT_HTML
and also
CHAT_ENABLE
that have been defined.
The modifications I have made are optional, what you really need to do is to include one file in the other using include
.
If you do not want include()
(or similar) then just use:
define("Chat_Enable", false); // -- Ativar/Destivar Chat do Servidor
define("Chat_Scripts", '<embed src="http://www.xatech.com/web_gear/chat/chat.swf"quality="high" width= "500" height= "300" name= "chat" FlashVars="id=158331371&rl=Brazilian" align="middle" allowscriptaccess= "sameDomain" type= "application/x-shockwave-flash" pluginspage= "http://xat.com/update_flash.shtml" /></embed>'); // -- Script do Chat
if(!Chat_Enable){
echo "<div class=\"info-box\"> O Chat se encontra Desativado</div>";
}else{
echo Chat_Scripts;
}
This will solve the problem because Chat_Enable
and Chat_Scripts
are set, test this here.