How to use PHP Type Declarations

PHP has developed into a more strictly typed language in recent years. Type Declarations help with that and are a fairly new addition to PHP, with recent releases improving them further. They give you more precise, concise code, clarity, validation, type-hinting and more. But first… what are Type Declarations? Take a look at this example:…

PHP Tips and Tricks

PHP: Hypertext Preprocessor is a scripting language that is a great tool for web developers to use when they want to produce dynamic web pages. Embed your PHP code into the HTML source and the PHP processor on the web server interprets it and generates the web page document. It does not matter if you…

Hide PHP Usage

If you are the web developer for a site, then you might not want visitors to know that you are using PHP for your scripting. One simple way around this is to use a different extension for the PHP files instead of the default .php. You can use any extension that you want including: .htm…

Send an email from PHP

It is common now for developers to use email as a means of communicating with users from the web site. There are many reasons that you might want to do this including: Confirmation of user action Password reset Send error logs to site administrator Before you start to configure your PHP scripts to send email,…

Error reporting with PHP

When you are working on your website, you will sometimes want to change the level of error reporting that your code returns. This is a great way to get full diagnostic information so that you can fix a problem in your latest piece of code, but be careful to only show error reporting on your…

Ignore User Aborts with PHP

When you are developing or supporting a website, it does not always work perfectly. Sometimes a visitor will abort a script that is running and when that happens you want to try and avoid that causing a client disconnect. The ignore_user_abort() function determines whether the remote client can abort the running of the script. This…