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

  • SEARCH
  • Home
  • 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 4235796
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:33:03+00:00 2026-05-21T02:33:03+00:00

Possible Duplicates: Reference – What does this symbol mean in PHP? In, PHP, what

  • 0

Possible Duplicates:
Reference – What does this symbol mean in PHP?
In, PHP, what is the “->” operator called and how do you say it when reading code out loud?

This is a really newbie question, so apologies in advance, but I’ve seen -> used several times in example code, but I can’t seem to find any explanation in online tutorials for what it does. (Mainly because Google ignores it as a search term – doh!)

Here’s an example that confuses me:

<?php
class customException extends Exception
{
public function errorMessage()
{
//error message
$errorMsg = 'Error on line '.$this->getLine().' in '.$this->getFile()
.': <b>'.$this->getMessage().'</b> is not a valid E-Mail address';
return $errorMsg;
}
}

$email = "someone@example.com";

try
  {
  //check if
  if(filter_var($email, FILTER_VALIDATE_EMAIL) === FALSE)
    {
    //throw exception if email is not valid
    throw new customException($email);
    }
  //check for "example" in mail address
  if(strpos($email, "example") !== FALSE)
    {
    throw new Exception("$email is an example e-mail");
    }
  }

catch (customException $e)
  {
  echo $e->errorMessage();
  }

catch(Exception $e)
  {
  echo $e->getMessage();
  }
?> 

What is going on in lines such as echo $e->errorMessage();? It looks like its passing the variable $e to the function errorMessage(), but if so, why not just do it in the more traditional way?

Thanks for any help.

  • 1 1 Answer
  • 1 View
  • 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-21T02:33:04+00:00Added an answer on May 21, 2026 at 2:33 am

    No, it is not a scope resolution operator. :: (also called Paamayim Nekudotayim) is the scope resolution operator, see the manual.

    No, it is not a function. This is object oriented programming, so the correct term is method.

    No, it is not a property. Again, it’s a method.

    I am not aware of any terminology for the -> construct. It is used to either call methods or to access properties on an instance of a class. On an object. I suppose you could refer to it as the “instance operator”.

    In your specific case it’s a method call. The errorMessage method is being called on your $e object, which is an instance of the customException class.

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

Sidebar

Related Questions

Possible Duplicates: Reference - What does this symbol mean in PHP? what do “=&”
Possible Duplicates: What does “=>” mean in PHP? Reference - What does this symbol
Possible Duplicate: php == vs === operator Reference - What does this symbol mean
Possible Duplicates: Reference - What does this symbol mean in PHP? What does @
Possible Duplicates: Reference - What does this symbol mean in PHP? What is the
Possible Duplicates: Reference - What does this symbol mean in PHP? Should I use
Possible Duplicate: Reference - What does this symbol mean in PHP? I have a
Possible Duplicate: Reference - What does this symbol mean in PHP? What's the difference
Possible Duplicate: Reference - What does this symbol mean in PHP? Found an image
Possible duplicate of Reference - What does this symbol mean in PHP? What does

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.