Right now I am onto the last two common errors that I have included.
And we will start with the hard one.
This is php header and we are using "header" function going to a location.
And here I have got some html code.
This is a header tag, I am saying "Welcome!".
And our "goto" variable is "google dot com".
If the "goto" exists, which it currently does, we are going to redirect the page to a u-r-l "google dot com".
Right now, this will return an error.
And the error is - Oh! um... Okay that’s why. "o b start".
Lets get rid of this. That wasn’t supposed to be there. That code is to fix the error!
Sorry, so we will go to "php header" and we have got "Welcome!" - our html code.
Then a warning - "Cannot modify header information – headers already sent by..." and all of this.
Okay so our headers have already been sent. This is the line no. by the way.
1, 2, 3 so if it gives you an error like "phpheader dot php" colon 3, then the error has occurred on the line no. 3.
So that's where the error is - on line 3, okay?
And this error has been generated by line 9, which if you go here, is our "header" function.
So the reason that this is happening is we are already sending our html code.
If I get rid of this by commenting it, and I were to refresh then we would be redirected to google.
But the point is that we want this welcome header here.
And you can’t actually put html before a header function, going to location and other features of this function.
You shouldn't do so.
So as you saw a minute ago that is "ob underscore start".
What this does is, it fixes this problem for us.
So I can come here to "phpheader" and it works, even though I have still got my html code echoed here before my header.
So without this we get an error (pause) and with this our header works fine, okay?
Despite the initial rule of no html output before header up here.
That should be pretty clear by now.
Now, the last one is extremely simple.
I don’t even need to explain it but anyway.
This is "include a file which doesn’t even exist" named as "idontexist dot php".
So lets have a look. Um.. where is it? "missing dot php".
Oh no! Its not. "open dot php".
Okay! So - include "idontexist dot php" failed to open stream; no such file or directory in that name here.
Our file name and directory on line 3.
So lets come to line 3.
And that is the only line of significant code in this file.
We have another warning here - Failed to open "idontexist dot php" for inclusion and all of this. So we get two errors.
This is quite messy when you have a page that has "include a header file".
Then these don’t look too nice. I mean you have probably been in a website before and you have seen this at the top.
You need to be attractive. So you can put a "@ (at)" symbol in front and refresh.
That won't show the error anymore.
But it doesn’t excuse the fact that the file doesn’t exist.
So the content of the file which doesn’t exist, won’t be included.
But yes, to be honest, looking at this, this is really pretty much self explanatory. I just thought I should explain this anyways.
So we have got a small collection of errors that you might come across when you are programming in php.
If there are other errors that you are getting, then please message me and I will be happy to help.
Please subscribe for latest updates. Thanks for watching. This is Evan Varkey dubbing for the Spoken Tutorial project.