I will call you back again to another video lecture in PHP.
And in this video lecture, I'll go ahead and teach you how to include PHP file in your PHP program.
Okay.
So we're going to include another PHP file into our PHP program.
And I'm going to teach you how to do that.
So in this case we are working on a PHP five course site dot PHP and want to create another PHP file
called blog dot PHP.
So what to include a blog page on our website.
So how do we do that?
Go over to a folder right in here.
Right click on this and click on a new file.
So let me go ahead and call out to be my blog dot PHP.
All right.
Go ahead and hit enter.
And I have my blog dot PHP right in here.
So inside is my blog of PHP.
I'm going to have a blog title.
I'm going to have a blog auto.
I'm going to have a comment so people can connect to my blog.
And let's go ahead and say the block title is going to be like H2 and go ahead and close the H2.
So inside here I'm going to include a PHP file that's going to pop out the title of this blog.
But that's also the name of the title will be Dot right in here.
What I'm going to create a variable of that title right in here.
So let's go ahead and show you how to do that.
So what I'm going to do is I'll go ahead and include PHP, so P, PHP and go ahead and close that.
So what are we going to put in right here.
And I'm going to say PHP equal the let me say this is my blog title.
So this is the variable.
But this variable has not been declared because I'm going to declare this variable right in here.
What I'll echo the variable name.
So this is going to be popped out okay from my blog page.
So everything will be shown on my blog page.
But I'm going to declare that variable and give it a name right inside the site dot PHP.
But whatever I'm going to do on that blog will be done right in here.
Now, I've done this and now go ahead and see.
The next one is the blog portal.
So to score and change this to maybe like a hash three so that the heading count becomes smaller and
go ahead and close that.
Now I'm going to I'm going to go ahead and put in p h p and go ahead and close that as well.
Now I went ahead and echoed.
Let me say blog author.
So this is the author of the blog.
And then for the comment section is going to be a paragraph.
And we're going to say paragraph.
And go ahead and put in PHP and go ahead and close this as well.
So I'm going to close my paragraph tag.
And from here I'll go ahead and echo this.
I'm going to say this is echo.
And then this is a blog comment.
All right.
So I have the blog title.
I have the blog auto.
I have the blog comment and it is ready right now.
But what I need to do is I have to go and declare all these the title, the author and the comments
right in here.
So I'm going to go to my PHP right in here, and I walk ahead and start the declaration on this guy
and say, so let me go back right in here.
And for any one of them I just copy this, okay, I'll just copy this and then I'll go ahead and paste
that.
And I'm going to set the blog title is going to be PHP blog.
PHP blog or.
Okay.
That is the key is any name you give.
Okay.
You will not find anything right in here.
We just want to learn about including the PHP file.
Now come here and go to the auto and lady auto.
Be equal to George Steve and put semicolon at the end.
And the next one is the comments.
So the PSP comment, the blog comments.
So go ahead and press that and let the blog commence.
So this is going to be equal sign.
So because you need to declare that and then go ahead and say beautiful blog.
Beautiful blog beach.
All right.
So this is a beautiful blog page because you're going to build an awesome blog page right in here.
So go ahead and save this.
So the next thing we need to do is to go ahead and include this PHP file called my blog dot PHP.
We need to include that so we can be able to print that out.
So if I go ahead now all I need to do is go ahead and use the include.
And then I'll go.
I'll include my my blog dot p h p.
And once you do that, place semicolon at end and go ahead and save this so you can see I've saved this.
Now let's go over here refresh and check it out.
So I have PHP block, which is this.
I have a block judge Steve, which is this.
I have beautiful block which is this.
And remember, that's everything I'm doing is right from here, because I cannot actually go right in
here and modify this to be maybe this is hash one or change this to hash one or save this and let's
refresh.
You can see it's now big.
Okay I can change this to H6.
I can change maybe the block order to h6, I save this, let's refresh.
You can see that Steve is now smaller and the paragraph is to the paragraph, the beautiful block page.
So now it is easier for me to include this.
My block dot php right inside the sites dot PHP is in the include, so you only include.
I was able to actually do that and now I can also create a function right in here.
And I'm going to call that function into the PHP.
Let me go ahead and teach you how to do that.
So you want to create a function.
Go ahead and create a PHP file.
So go ahead and close this.
And right inside here this car head and create a function.
So I'm going to give this a function name.
Let's go ahead and say.
Function.
And let the name of the function be hello world.
And world hello world is going to do is just going to say um welcome to PHP.
So welcome to PHP or hello welcome to PHP.
All right.
So now I'm going to put in name.
So I'm going to put this a name when I'm passing the name right in there.
So it's going to call your name.
And you're going to say Jorge welcome to PHP.
That's what I'm going to do.
And uh, let's go ahead and uh, call this, I'm gonna say.
See, I'm going to pass a name.
So you're going to call your name first and I'll tell you to work on to FB.
I see.
Welcome.
Welcome to FB.
I might go ahead and put a semicolon at the end.
And now I'm going to go over here.
So anytime you want to call a function right in here it shows that you have already included this.
It was actually include this because if this goes above this place you're going to have an error.
So I'm going below and not above.
But if I want to declare your variables then I have to always be above the include function.
Now under the include I'm going to call the function name which the function name is hello world.
All right.
So go ahead and copy that.
And I'm going to say hello world.
And then I'm going to pass in the name I want maybe judge.
work onto hello world.
So please, semicolon at the end of this and let's save this.
Now let's go ahead and refresh this and check it out.
Judge.
Welcome to Hello World.
Okay.
So I can put semicolon at the end okay a comma.
And then it says Jorge welcome to PHP.
So I can see I was able to include a function like code right in here.
And now I was able to call the function inside sites dot PHP.
So you can actually do that.
Use one page to do some things, and then come over to your main page and call the functions.
And this kind of work out fine.
And so beautiful.
This is the way you can actually include, uh, a PHP file into another PHP and work on your project.
So I hope that is beautiful.
Kind of play around with it, check it out, try it more as possible to enhance this and do more.
And lots of things under here.
So if you have any questions, please go ahead and use the question and answer section.
And I'm going to get back to you as soon as possible.
Thank you so much.
And I'm going to see you in the next video lecture.