PHP Returning Variables OOP vs Procedural


PHP Returing Variables OOP vs Procedural PHP

Returning variables from PHP OOP is slightly different from that of returning variables with procedural PHP.

With procedural PHP, the function can return a single variable, but it is accessed by setting a function equal to a variable.

With OOP PHP, you can call a method and return your desired variable. The variable returned from an OOP PHP function is output immediately.

An easy way to remember this is that returned variables with procedural need to come from a variable that is equal to a function and OOP PHP just returns it without any questions asked.