Skip to content
Advertisement

how to hide properties of class during serialization?

can i override function that is responsbile for serializing and Php class to an array/stdclass so that i can implement my own logic “like hiding certain attributes based on condition)

JavaScript

Advertisement

Answer

How about implementing the Serializable interface? Looks like you can do your custom logic by implementing the interface methods.

Example:

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement