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 8535783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:30:52+00:00 2026-06-11T10:30:52+00:00

This is a very straightforward question that doesn’t appear to be directly addressed at

  • 0

This is a very straightforward question that doesn’t appear to be directly addressed at php.com – at least from looking through that section.

In any case, I have a class here with a specific function:

class CheckOut extends DB_MySQL{

public $fName;
public $lName;
public $numberOut;
public $p_id;

    /.../

    protected function publisherCheck($lName, $fName)
    {
        $this->lName = $lName;
        $this->fName = $fName;

        //Execute test
        $this->checkConnect();
        $stmt = $this->dbh->prepare("SELECT p_id FROM People WHERE lastName = :param1 AND firstName = :param2");
        $stmt->bindParam(':param1', $this->lName);
        $stmt->bindParam(':param2', $this->fName);
        $stmt->execute();

        //Determine value of test
        if($stmt == FALSE)
        {
            return FALSE;
        }
        else
        {
            $p_id = $stmt->fetch();
        }

    }

Just ignore the fact that there is no constructor posted with missing functions, etc. They’re in this class – just not pertinent to my question.

Will setting $p_id in the last statement affect the variable declared initially in the header of the class? Essentially, will it be global within the class?

Any help is appreciated.

  • 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-06-11T10:30:54+00:00Added an answer on June 11, 2026 at 10:30 am

    Nope, it won’t. You always need $this-> to tell PHP you’re talking about the class properties, not local variables.

    // Always assignment of a local variable.
    $p_id = $stmt->fetch();
    
    // Always assignment of a class property.
    $this->p_id = $stmt->fetch();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is likely a very simple question with a straightforward answer but I'm something
this is a very straightforward and easy question. So please give me an easy
Very straightforward CSS question that I haven't been able to find the answer to
I have this very straight forward question regarding Thread and Timer classes in Java
Apologies or asking what is probably a very straightforward question, but I'm new to
This is a pretty straightforward architectural question, however it's been niggling at me for
This probably comes across as a very naive question, and I am absolutely assuming
Very straightforward question: I've built a slider with (dynamic amount of slides), with a
It seems there are some very good resources on my question - at least
Okay so I am a little confused. This should be a simple straightforward question

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.