• 7

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Echo command doesn't do anything

I've been started studying PHP in my spare time, and the first code example I was given was this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        echo "Hello World";

From what I understand, this should write out "Hello World". However, all I see is a blank webpage. Any ideas why this is and how I should go about fixing it?

    • any solutions to this? I have the same problem! I'm very new to php and I have a index.php on my desktop which does not work
      • 2
    • @AdamP - Did you ever find the solution? I'm curious. My initial thought was it wasn't a .php file, but I see that it was. Was it because you didn't have PHP properly enabled on your machine?

Here's a checklist

  • What server are you running? Does it support php?
  • Is PHP enabled?
  • Is your file named with the extension .php?
  • When you use View Source can you see the code in the php tags? If so PHP is not enabled

As a test try saving this as info.php


and see if it displays information about your server

  • 13
Reply Report
    • I am using an FTP server from my local ISP. When I view the source, I can see the code in the php tags, so I guess that means PHP isn't enabled. Is there something

Make sure the file that contains that code is a PHP file - ends in '.php'.

  • 1
Reply Report
      • 1
    • And that the web server is configured to actually run it through PHP. If he's on a web host, that should be done for him, but if he's setting up a server at home it might not be.
      • 2
    • The file does have a .php extension and I'm on a web server so I don't think either of those are the problem. Thanks for trying though.

The code seems fine, certainly it should do what you intend.

Probably what happened is that you named the file with something like example.html, so you have to check the extension. It must look like example.php. With the extension .php at the end of the file you are telling the webserver that this file contains php code in it. That way the <?php echo "Hello World"; ?> is going to be interpreted and do you intend it to do.

  • 1
Reply Report
      • 1
    • I've already checked that the file has a .php extension several times, so I doubt that that is the problem. Thanks for trying though.

If you don't see the html tags in the source, it means there is a PHP error. Check your view source, and if nothing is shown, check your error logs.

  • 0
Reply Report

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions