PHP require not working

Posted October 24, 2019 11.8k views
ApachePHPPHP FrameworksDigitalOcean 1-Click Apps Marketplace

I have installed my droplet (ubuntu 18.04) both manually but also tried the one-click apps. Both times the PHP variables are “undefined” but they are defined in another file. I used the following code to include them:
require ’/var/www/developer/steamauth/userInfo.php’;

This works on my other server (Linus @ ExtraVM) so I don’t understand why this doesn’t work. Am I missing any PHP packages?


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers

Hi @PixelBoii,

I’ll recommend checking the following article - Ubuntu PHP - How to

It will help you properly install PHP and every packages needed on an Ubuntu.

I’m unsure what you mean by PHP variables not working with require though. Can you please give a little bit more information on the matter?

by Mark Drake
by Erika Heidi
A "LAMP" stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This stack typically consists of the Linux operating system, the Apache web server, a MySQL database, and PHP, a dynamic content processor. This tutorial serves as a guide for installing these components on an Ubuntu 18.04 server.
  • I’ve already tried that tutorial without much success. The error is:
    PHP Notice: Undefined variable: steamprofile in /var/www/html/index.php on line 109"

    Line 109:
    <p style=“color: #000;”><b>Your SteamID 64 is:</b> <?=$steamprofile[‘steamid’];?></p>

    All the errors are like this one, just different lines. All php steam related.

    • Hi @PixelBoii,

      Thanks for the explanation, I now know what you mean.

      Can please make sure you’ve required/included the file at the top of the document and make sure these variables are actually being called in someway by your script/website?


      • Absolutely. This is the top of my file:

          require '/var/www/html/steamauth/steamauth.php';
          require '/var/www/html/steamauth/userInfo.php';
              $id = $_SESSION['steamid'];
            # Not logged in
        <!DOCTYPE html>

        and then the html goes on..