/    Sign up×
Community /Pin to ProfileBookmark

Alternative to print_r?!

I am writing a custom debugging function and need to print some objects to the screen.

print_r does exactly what I need except it also shows private and protected members of the object shown. I need to return the string to the browser without them.

Is there an alternative function that does that?
If not then is there a way to remove them? (ive tried using regular expressions but couldn’t do it)

thank you

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 17.2012 — I believe that if you call [url=http://us3.php.net/manual/en/function.get-object-vars.php]get_object_vars[/url]() from outside of the object, you get only the public variables.
Copy linkTweet thisAlerts:
@paishinauthorApr 17.2012 — you are right! Running it outside the class does not return the private/protected members of the class.

I had already tried this function but it was within the object i was trying to print so I didnt realize it would behave differently outside the class.

thanks once again
×

Success!

Help @paishin spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...