0

When I type somewhere in my code

<?  
require_once(dirname(__FILE__) . '/../../inc/config.inc.php');

if ($Admin->Connected && $Admin->HasRight('menu_Contact_Subscription', USER))
{

It shows me an raw output like this on the screen:

Connected && $Admin->HasRight('menu_Contact_Subscription', USER)) {

Why does this happen?

insertusernamehere
  • 23,204
  • 9
  • 87
  • 126
Anonymou
  • 25
  • 5
  • Is it only one block of code this is happening to. Or does it echo the entire file? – Ben Hillier May 07 '19 at 07:41
  • Possible duplicate of [PHP code is not being executed, instead code shows on the page](https://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-instead-code-shows-on-the-page) – insertusernamehere May 07 '19 at 07:44
  • It could be that something in `config.inc.php` is causing this problem. Does that open or close tags anywhere? – Ben Hillier May 07 '19 at 07:44
  • 1
    my suspicion is that config.inc.php has something strange in it, that let's php think that `->` is the end of something...a docblock maybe? but I am confused, too, I've never seen this behaviour. You could try to copy the content of the config.inc.php into the code file and see if your editor's syntax highliting gives any hints – cypherabe May 07 '19 at 07:44
  • @insertusernamehere In this case, I think there's something more going on than just a PHP file failing to execute. Otherwise, the entire `if` statement would be echoed. – Ben Hillier May 07 '19 at 07:46
  • 2
    @BenHillier [Why do you think so?](https://jsfiddle.net/avermno9/) ;) – insertusernamehere May 07 '19 at 07:54
  • 2
    @insertusernamehere I stand corrected. It's interpreting the tags as HTML of course! Then indeed: the PHP is simply failing to execute. – Ben Hillier May 07 '19 at 07:57
  • @insertusernamehere of course, you are right. do you want to expand your explanation into a beginner-friendly answer? – cypherabe May 07 '19 at 08:00
  • Php should give expected output. If not this may have a lot of causes. Check related functions if there's mistakes. Especially if you use header(); function it usually gives errors similar to this. – Creative87 May 07 '19 at 08:10

2 Answers2

1

replace:

<? 

with the following:

<?php
oreopot
  • 3,392
  • 2
  • 19
  • 28
0

Please Check php opening tag <?php I think so;

SAVe
  • 814
  • 6
  • 22