Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7076907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:21:21+00:00 2026-05-28T06:21:21+00:00

There are lots of Why does PHP throw an error here? questions. Well, this

  • 0

There are lots of “Why does PHP throw an error here?” questions. Well, this is a little different. I found the following code while reworking some code written by a coworker:

foreach($arr as $key => $value) {http://google.com/
  echo $value;
  // ...
}

My first thought: “Umm…how embarrassing; he must have accidentally pasted that in there…” followed by: “Wait…there’s no way this code actually runs…that should be a syntax error”. And yet:

 $ php -l test.php
 No syntax errors detected

And indeed, (like so much PHP code that seemingly shouldn’t run) it runs in production without trouble. So I did a little testing:

foreach($arr as $key => $value) {http://google.com/ <-- original, no error
foreach($arr as $key => $value) {http: <-- also no syntax error
foreach($arr as $key => $value) {http  <-- bingo! "Unexpected T_ECHO..."

What little tidbit of PHP’s grammar is producing such strange results?

(I am using PHP 5.3.5)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:21:22+00:00Added an answer on May 28, 2026 at 6:21 am

    The http: is being interpreted as a label (which are used for goto statements), and the //google.com/ as a comment (which can easily be seen through syntax highlighting).

    Documentation on goto:

    The goto operator can be used to jump to another section in the program. The target point is specified by a label followed by a colon, and the instruction is given as goto followed by the desired target label.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There are lots of PHP articles about the subject so is this a PHP
There are lots of questions on how to improve communication between teams. One way
There are lots of IDEs for PHP development, but I'm curious about all the
There are lots of source code formatting tools out there. Which ones work best
I'm trying to learn PHP programming through trial, error and lots and lots of
I found there are lots of posts showing how to detect if the application
I have 2 branches here, say branch1 and branch2. There are lots of new
Why I ask this question: I know there have been a lot of questions
Well, it's not an error, actually. I have wrote a game. There is only
My Code Igniter app has urls like this: http://servername/contexttroot/index.php/Sessions/login/ My question is, when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.