在php文件中包含('xyz.php')不起作用

I'm trying to include a php file inside another php file, but it is not working and I don't know why.

Moreover, I'm getting no erroes. allow_url_include is enabled in php.ini file.

I'm using XAMPP server.

Below here is part of my code:

q.php

<div class="article">

<? php
include ('a.php'); 
?>
</div>

where a.php simply has echo statement:

echo "hello";

I'm posting bigger section of my code now.

<div class="artical">
    <?php
        $username = "root";
        $password = "";
        $database = "techinsight";
        $server   = "127.0.0.1";

        $db_handle = mysql_connect($server, $username, $password);
        $db_found  = mysql_select_db($database, $db_handle);

        if ($db_found) 
        {
            $SQL    = "SELECT * from questions";
            $result = mysql_query($SQL);

            while($db_field=mysql_fetch_assoc($result))
            {
                $x = $db_field['Qid'];

                while($x==1 && $x==NULL)
                {
                    $SQL      = "SELECT * from questions";
                    $result   = mysql_query($SQL);
                    $db_field = mysql_fetch_assoc($result);

                    $x        = $db_field['Qid'];
                }
            }

            if($x==$x) 
            {
                for($x; $x>0; $x--)
                {
                    $SQL      = "SELECT * from questions WHERE Qid=$x";
                    $result   = mysql_query($SQL);
                    $db_field = mysql_fetch_assoc($result);
                    $str_que  = $db_field['question'];

                    echo "<div class='dabba'>
                    <div class='block_a'> <?php include('a.php'); ?>  //here it is.
                    </div> <br>
                    <div class='block_b'>
                    it is 2nd section. <br>
                    </div><br>
                    <div class='block_c'>
                    last one.<br>  </div>

                    </div>  <br><br>";      
                }
            }                                    
        }     
    ?> 
</div>

Try:

<?php //Before you had <? php <--
include "a.php";
?>

Make sure the files are in the same directory.

You have a space between <? and php Remove it.

It can be a couple of things...

1. Place the included file in the correct folder

Make sure that when you use include you either provide the folder path correctly or place the file in the same folder as where you reference / call it from.

2. It is <?php and not <? php

You have a space too much. Actually, if you use <? php I believe PHP will look for a function called php as <? may also be an opening tag (assuming short tags are activated in your php.ini file: short_open_tag=On).

Bonus: make sure error reporting is turned on while debugging

Another thing that I'd recommend you to do is to setup your php.ini file to report for all errors while debugging:

error_reporting(E_ALL);

I haven't tested it, but I'm pretty sure your above code would have resulted in a notification on the missing function php.

And the real bonus (following your updated post) - what you did wrong

You have added the include inside echo - obviously it won't work. So replace this...

echo "<div class='dabba'>
                <div class='block_a'> <?php include('a.php'); ?> ...

...with this...

 echo "<div class='dabba'>
                <div class='block_a'>"; include('a.php'); echo "...