简体   繁体   中英

PHP $_SESSION stops execution

I was trying to get my OS X localhost PHP scripts to send mail, so I followed this tutorial . I was able to get mail( ) to send after completing the article, but now something is wrong with sessions.

I have a page that used to work with the following:

<!-- ... -->
<?php include( 'search-form.php' ); ?>
<?php include( 'site-navigation.php' ); ?>
    </body>
</html>

Now, the page rendering stops at the site-navigation.php include. I was able to locate exactly what line stops execution and it is the if-statement below:

site-navigation.php :

        <section>
            <h2>Site Navigation</h2>

            <nav>
                <ul>
                    <li>
                        <a href="index.php">Home</a>
                    </li>
<?php
if( isset( $_SESSION['uid'] ) ) :
?>
                    <li>
                        <a href="view-user.php?uid=<?= $_SESSION['uid']; ?>">User Profile</a>
                    </li>
                    <li>
                        <a href="logout.php">Logout</a>
                    </li>
<?
endif;
?>
                </ul>
            </nav>
        </section>

Commenting that out allows execution to proceed, but what could I have done to cause it to stop working as it did before? I really don't want to do a full reinstall, but if I have to, so be it.

My only guess is that when I copied php.ini.default to php.ini it overwrote some settings that I didn't know I had. What could those settings be?

I found out what the problem is. It appears that short-tags are not working.

Changing:

<?
endif;
?>

To:

<?php
endif;
?>

Allows execution to proceed. Now, I just need to figure out how to get short-tags working again. Or, better yet, fix my code so it doesn't have these unnoticed anomalies.

Thanks @Wrikken for helping me figure it out.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM