I am wondering if it is possible to add new class data members at runtime in PHP?
Yes.
$prop = 'newname'; $obj->$prop = 42;
will do the same thing:
$obj->newname = 42;
Any of these will add "newname" as a property in $ obj if it does not already exist.
It. You can add public members, run-time without additional code, and can affect protected / private members using the magic __get () / __ set () overload methods. See here for more details .
Source: https://habr.com/ru/post/1697837/More articles:How to get Single XElement object using Linq for Xml? - c #Writing a Scheduled Windows Service in .NET - .netWindows hangs during headless build - installerMoq'ing interface - c #Flash banners conflicting with pop-up blockers? - flashModification of key points - morphingHow to enable STRICT_ALL_TABLES 'for a single MySQL database? - mysqlHow can I list the DSNs configured on a computer using VBA? - vbaInstalling .NET 3.5 on a server with .NET 2.0 applications - asp.net-2.0Team Foundation Server Port 8080 ASMX Access Issue - tfsAll Articles