O'Reilly logo

PHP and MySQL Recipes: A Problem-Solution Approach, Second Edition by Frank M. Kromann

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Frank M. Kromann 2016

Frank M. Kromann, PHP and MySQL Recipes, 10.1007/978-1-4842-0605-8_2

2. Classes and Objects

Frank M. Kromann

(1)Trabuco Canyon, California, USA

Object-oriented programming provides many advantages over procedural programming. It helps with encapsulation when code is shared within a team or between teams and it can help protect elements of the code from being abused. This is especially the case when code is shared in compiled form but the same mechanisms can be applied to a scripting language like PHP. This chapter describes how object-oriented programming works in PHP.

Recipe 2-1. Writing a Simple Class

Problem

PHP can be used as a procedural programming language, but you want to make use of the many features of object-oriented ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required