Is there anyway to prevent var_dump from printing private vars in a class? I got a private var for DBPASS and this surely shouldn’t be printed when using
var_dump($this->db);
as
["db_host:private"]=> string(9) "localhost" ...user, pass, etc ...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
No, you can’t. Note that private variables were not made to hide passwords – at least not in the sense that you are implying. Arguably they could all the public and it would make little difference to the security of your application, if that’s what you are concerned about.
You have full control over where
var_dump()is used, it’s not like it magically pops up to show your password to an end-user. You really shouldn’t have any kind of debug code in a production environment anyways.