Monthly Archives: October 2022

OOP IN PHP FIFTH PART

THE MAGICAL DESTRUCT METHOD Usually the constructor is invoked automatically during the creation of an object, it is used to initialize the properties with the values passed in input, in general it initializes properties and services used by the class, by services I mean other objects that the class may need. Similarly when an object no longer needs to be in memory or because the script terminates or because there are no more references to that object PHP calls the method __destruct (). The method __destruct () is not a real destructor but it serves to do some operations [...]

By |2024-09-11T07:03:19+02:001 October 2022|0 Comments

HANDLING ERRORS IN PHP

DISPLAY ERRORS AND ERROR REPORTING With this function ini_set (' display_errors ', 0 ); we disable the display of errors . For example, we do not display a warning on an undeclared variable. If we set display_errors to 1 we activate the display of errors and display a warning on an undeclared variable. display_errors only concerns the display of errors within the page, error_reporting writes a log file with the errors or warnings that have occurred . If we set error_reporting to 0 even if display_errors is set to 1 we do not display errors. If we don't want [...]

By |2022-10-13T21:23:21+02:0013 October 2022|0 Comments

THE EXCEPTIONS IN PHP

EXCEPTIONS IN PHP INTRODUCTION TO THE EXCEPTIONS Since PHP 5 we have the exception mechanism available. If we ask a user to enter a number between one and ten, the exception is when the number is outside this range. When we talk about exceptions we are talking about objects of class Exception. Let us take an example with the class FileManager. One exception arises with education throw new Exception If we raise an exception someone somewhere will have to handle it, if not a fatal error occurs. Exceptions are caught with blocks try (try running the following code) catch [...]

By |2024-09-12T05:45:15+02:0015 October 2022|0 Comments
Go to Top