Jump to content

Need help doing a var_dump on a property


Go to solution Solved by denno020,

Recommended Posts

Hey Guys. I am trying to see if my page retrieved the $_SESSION['store_name']  in the checkout_class_model.php page

 

In my validation class I set the $_SESSION['store_name'] to be assigned to the $store_name property in the __construct method. I then tried to do a var_dump on the store_name property, but didn't seem to work. Below is my class. Thanks in advanced!

class validation {


  public $store_name = "";
   
   
   public function __construct() {
     
     // Automically checks if store is closed 
    if (is_store_closed()) {
   goto_page($store_name);
   //Sets to session store_name 
   $this->store_name = $_SESSION["store_name"];
   var_dump($this->store_name);
    
    
}

The validation class is then included in my form.php page

  • Solution

The first thing I notice is that the if statement doesn't seem to have it's closing curly brace?

 

Apart from fixing that, there are 3 things I would check:

1. var_dump() as the very first thing in the constructor, this will tell you if the object is being instantiated or not (speaking of which, can you show us the code where you create a new validation class)

2. var_dump() is_store_closed() outside of the if statement, to make sure that's returning true.

3. var_dump() the $_SESSION variable, even though doing a var_dump of $this->store_name should display null.

 

I think you problem is either you haven't created a new class properly (you can't just include the script, you actually have to call $validation = new validation() ), or you is_store_closed() function is returning false.

 

Hope that helps.

Denno

Hey Denno! Thanks for the reply! You where right I was missing a closing curly brace. Good catch! I went ahead and added it. I also did a var_dump on just the session , which it displayed. I then did a car dump on the $this->store_name and it also worked. Thank you very much for your help. I really appreciate it!!! :happy-04:

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.