Using references in PHP can be sometimes confusing especially if you don’t exactly understand their purpose. Let’s take a look at $this
, self
and static
references using simple examples to explain their usage in an easy to understand way.
Let’s start by taking a look at the following example:
Executing the script above will result in echoing:
0
1
There’s no doubt about it since $this
always refers to the instance itself on which the method is called (or the attribute accessed).
Since there’s no multiple inheritance in PHP (yet) you can imagine it simply as a queue of…
Have you been using XAMPP for a while and every time you want to access your project you’ll do one of the following:
localhost/my-project-folder
If that’s you’re case then you’re in luck ‘cuz there’s a more sophisticated way of doing so that’ll let you have as many domain aliases for all your projects as you’ll need just in four steps.
First you’ll need to set up a new entry in the hosts…
PHP developer | University student | Tutor