Workshop

Quiz

1: What keyword would you use to define a class constant?
2: A static property cannot be changed at runtime. True or false?
3: Can a static method access normal object properties using the $this pseudo variable?
4: What built-in method could you implement to catch an attempt to access a nonexistent property?
5: How would you prevent a method being overridden?
6: What built-in method will be called when an object is about to be destroyed?
7: What keyword would you use to send an exception to client code?
8: What clause would you define to handle a specific exception in client code?
9: How would you instantiate an abstract class?

Answers

A1: You would define a class constant with the const keyword:
const DJ="John Peel"
A2: ...

Get Sams Teach Yourself PHP in 24 Hours, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.