That was a very thorough and clear explanation about how to include files. I am learning SO MUCH from each video. 👍👍 I don't think a thousand thank yous would ever be enough to acknowledge all the time and effort that you've put into these training videos.
Very happy to hear that. You're welcome & for me the biggest motivation is exactly this that you & many others are learning & finding my videos useful. So thank you
Okay now, I must confess this tutorial is really good. The instructor uses succinct and straight-to-point approach to explaining things so the student ends up learning all the way. Gio has no idea how very grateful I am, as in like "ki lo de!" Thank you so very much. I recommend this tutorial for anyone interested in learning PHP.
It takes between 1-2h to chew through 8 min of this video. So much info. This video alone is 5.5 A4 pages with all the code samples. Thanks for great content.
New and profound things with each lesson. What is true (include()) for NAV is also true for HEAD and at the end of the page, for different styles and scripts
@@ProgramWithGio I guess that comment was just to add to your teaching that not only a nav-file can be extracted and included but head-file and footer-file as well. Of course EVERY file can be added.
Always a pleasure to have these deep dives into the elements of PHP! Best tutor Gio! In the beginning require and include kinda confused me (I'm often confused, am I? 🧐) A small point I missed and that could be helpful is the mixture of require, include and require_once, include_once. I guess its often result from copy pasting of other peoples code. In only few cases it really makes sense but often it makes no problems. Thats possibly why people stick with it. Maybe I'm too old but I like when (especially if you have many options - and PHP could have the title "many options language") you program by reason and not random. Am I right when I assume that always using require_once could be a good strategy and only when your code either shows "I need it a second time" and/or "Its nice to have it, but its not strictly required" switch to one of the other options? I do something similar with "private" and "protected"/"public" later on in Objects.
thank you're really a great person, i got complicated from PHP output control functions because i searched for it after you used it in the video and i couldn't understand somethings it was complicated so i wish you will upload a video for it soon 😅
Hi Gio - One question to include and require - when I do 2 include/requirelines like this include_once 'includes/layout.inc.php'; include_once 'Classes/Database.php'; the top of my page (the first line gets empty and Nav bar in my else working bootstrap theme get pushed downwards... if I add 3 include/require et moves down 2 empty lines. I thought it would be a good idea to include from different files, depending of what I need, like in my example one file for database and one for layout... Question: is it my bootstrap that messes up or isn't it possible to include different pages? I tried with all 4 include/require functions. Love your lessons, though they are very fast - good we can rewind and push pause!!!
It's even easier in Svelte or any other JS framework for that matter. I haven't delved too much into PHP but if that's how it handles dynamic page generation, then it should be relegated to backend logic only.
Really nice tutorial. My question is on the str_replace(). Notice it's also changed the url from 'about.php' to 'About Us.php', which the give 'file not found' error. Any work around solution to this. Once more, thanks.
str_replace is case sensitive as far as I remember so it should only replace 'About' with 'About Us' it wouldnt replace 'about' lower case version. Try it out.
@@ProgramWithGio yes absolutely correct. The str_replace() is case sensitive. Replacing 'about' with 'About us' always changes the URL. The first parameter is case sensitive. From what I understand the str_replace() takes 3 parameters. First, the string you want to be replaced. Second, the required string and third, the variable that holds the string. In whichever way, it always changes the URL.
Great tutorial as always. Could you explain how str_replace() function change the content and what if file has multiple similar name then how str_replace() function work?
Bro as stated in last example If i take contents of a php file and inject it inside HTML file against a placeholder {{content}} inside body tag using the functions ob_start( ) and ob_get_clean( ) as you showed in the video in the last this is my practice.php file -------------------------------------------------- $x = 5; function foo(): void { global $x; echo "Hello $x"; } foo(); Expected output -- Hello 5 Getting the output as --Hello In the output I loose 5 .Does using a function as a string and injecting it in the layout makes it loose content in case of Global Scope? In rest of the cases I am getting expected output. Need your suggestion
@@ProgramWithGio I am practicing your entire PHP course video by video so this is the same example as you gave in video 1.23...:D Anyways I am in love with your PHP video series it has improved my knowledge a lot and has made me learn a lot more concepts...even some things I had never seen anywhere or heard of...Also shows exceptional effort you have put in your videos for including all sorts of content...:D
@@rxxt-sh1vj ah didn't realize you were using my example. In that video I was just showing it to illustrate an example, globals shouldn't be used in modern PHP, it's good to know what it is and how it works in case you are working on a legacy codebase. Thanks alot, I'm really glad that you like my videos.
@@ProgramWithGio Yes exactly - some people though might think that you need to put it on all require calls for it to work, not just those after the first call. 🙂
when using require two times in a same file i got redeclare error but didnt got it with require_once... but theres no error in ur side what might be the reason
require_once only includes it once, but with require, it would cause the error if you had a function in the file for example. If you are referring to the example at 2:15 there it's just an echo statement so nothing is being re-declared, if I had function, for example, it would cause an error.
Wait wait wait, are you really saying that if I include a php file into another I automatically have access to the variables and functions and that it can also overwrite the variables I have declared in my original file? What kind of dumb implementation is this? Wtf php??? Am I missing something??
Yes that can be considered a good or bad depending on how you look at it. It comes in handy for templating engine implementations & there are some other use cases but in general yes it can be tricky to work with which is why I avoid having variables defined in files that are being included in other files. Once you start using OOP & proper templating this shouldn't be a concern
Learning something new in every video. These are gems!
Thank you. Glad you liked it 🙌
That was a very thorough and clear explanation about how to include files. I am learning SO MUCH from each video. 👍👍
I don't think a thousand thank yous would ever be enough to acknowledge all the time and effort that you've put into these training videos.
Very happy to hear that. You're welcome & for me the biggest motivation is exactly this that you & many others are learning & finding my videos useful. So thank you
Really there is no other php course like this anywhere online either free or paid..congrats sir professor FOR IN DEEP PRESENTATION OF PHP
Thank you 💙
You are the best teacher I have ever seen online! Please upload new videos about other programming languages too.
Thank you
Okay now, I must confess this tutorial is really good. The instructor uses succinct and straight-to-point approach to explaining things so the student ends up learning all the way. Gio has no idea how very grateful I am, as in like "ki lo de!" Thank you so very much. I recommend this tutorial for anyone interested in learning PHP.
This is awesome to hear, thank you & happy to hear that you are finding these lessons helpful
It takes between 1-2h to chew through 8 min of this video. So much info. This video alone is 5.5 A4 pages with all the code samples. Thanks for great content.
Glad it was helpful
Lol, I'm glad to see that there are others that take notes from this course, I felt kinda old style when I started :-) But its soo much info^^
clean explanation. This is the best and legit PHP tutorial ever. Thank you .
Glad it was helpful. Thank you
Actually I was just thinking if there is any other one who is better in PHP than you.The BEST💯🙌👏
There are many that are way better than me, but thank you 🙌
@@ProgramWithGio I do not think so🙌👏
i am starting to watch your 70 videos more & more times
This lesson helped me a lot. Thanks a million!
Happy to hear
the best tutorial for beginners.
Thank you 💙
I learned a lot in this tutorial . I didn't know how to assign include file value in a variable and modify the content . Thanks
Happy to hear that 🙌
Thanks! Worked well for me :)
You're welcome
i really love this course i never watch some one explain everything about any other language like you. thank you so much
Thank you 💙
New and profound things with each lesson.
What is true (include()) for NAV is also true for HEAD and at the end of the page, for different styles and scripts
Hey, sorry for the late reply. Not sure I understand the question. Can you elaborate?
@@ProgramWithGio I guess that comment was just to add to your teaching that not only a nav-file can be extracted and included but head-file and footer-file as well. Of course EVERY file can be added.
Excellent. Man, i am loving it . God bless you Gio
Thank you 🙌
i finally have understood the difference between include and require )
That's awesome, happy to hear
You are awesome. God bless you. I keep learning more and more after each video
Thank you 🙌
Always a pleasure to have these deep dives into the elements of PHP! Best tutor Gio!
In the beginning require and include kinda confused me (I'm often confused, am I? 🧐)
A small point I missed and that could be helpful is the mixture of require, include and require_once, include_once. I guess its often result from copy pasting of other peoples code. In only few cases it really makes sense but often it makes no problems. Thats possibly why people stick with it. Maybe I'm too old but I like when (especially if you have many options - and PHP could have the title "many options language") you program by reason and not random.
Am I right when I assume that always using require_once could be a good strategy and only when your code either shows "I need it a second time" and/or "Its nice to have it, but its not strictly required" switch to one of the other options? I do something similar with "private" and "protected"/"public" later on in Objects.
Yup, I also use require_once most of the time
thank you're really a great person, i got complicated from PHP output control functions because i searched for it after you used it in the video and i couldn't understand somethings it was complicated so i wish you will upload a video for it soon 😅
Thank you 💙
these videos are legit. Brilliant stuff
Thank you
Great Tutorial
Thank you 🙌
great video. thank you.
Thanks
Thank you so much
You're most welcome
Hi Gio - One question to include and require - when I do 2 include/requirelines like this
include_once 'includes/layout.inc.php';
include_once 'Classes/Database.php';
the top of my page (the first line gets empty and Nav bar in my else working bootstrap theme get pushed downwards... if I add 3 include/require et moves down 2 empty lines. I thought it would be a good idea to include from different files, depending of what I need, like in my example one file for database and one for layout... Question: is it my bootstrap that messes up or isn't it possible to include different pages? I tried with all 4 include/require functions.
Love your lessons, though they are very fast - good we can rewind and push pause!!!
Most likely related to content/whitespace within your layout & other php files being included. I would need to see your setup to be able to help
thank you!
You're welcome!
Damn, this is a gem. thank you My Dear Sir...
Thank you 🙌
Learning a new tip today : . Thank you sir
That's great. You're welcome
.
გიო, გაიხარე! Including/rendering a separate component dynamically is much easier with php that with ejs. Nice one.
Thank you 🙌 მადლობა
It's even easier in Svelte or any other JS framework for that matter. I haven't delved too much into PHP but if that's how it handles dynamic page generation, then it should be relegated to backend logic only.
Like You lessons. Thnx
Thank you
You're welcome
this is the best php tutorial i have ever seen thank you for everything gio (by any chance are you georgian? :d)
Thank you 💙 and yes I'm Georgian 🙂
@@ProgramWithGio shemogevle gio seriozulad karg videoebs deb mitumetes dzalian momwons patara detalebzec rom laparakob romelsac sxvagan yuradgebas ar utmoben.warmatebebi da kidev ertxel didi madloba am umagresi videoebistvis ❤️
@@RedBaron19180 გაიხარე, მიხარია რომ ქართველებიც უყურებენ ჩემ ვიდეოებს 🙌🙏
@@ProgramWithGio aucileblad yvelas shevtavazeb am videoebis yurebas da movematebit :D
@@RedBaron19180 🙏🙏
Really nice tutorial. My question is on the str_replace(). Notice it's also changed the url from 'about.php' to 'About Us.php', which the give 'file not found' error. Any work around solution to this. Once more, thanks.
str_replace is case sensitive as far as I remember so it should only replace 'About' with 'About Us' it wouldnt replace 'about' lower case version. Try it out.
@@ProgramWithGio yes absolutely correct. The str_replace() is case sensitive. Replacing 'about' with 'About us' always changes the URL. The first parameter is case sensitive. From what I understand the str_replace() takes 3 parameters. First, the string you want to be replaced. Second, the required string and third, the variable that holds the string. In whichever way, it always changes the URL.
@@mimoh2000 I just tried it: 3v4l.org/8K4oM and it works as expected, maybe I'm missing something?
Here is the snippet with the exact nav: 3v4l.org/13noQ
as you can see in the result it does not update the url.
Great tutorial as always. Could you explain how str_replace() function change the content and what if file has multiple similar name then how str_replace() function work?
str_replace just replaces all occurrences of the search term with whatever you give it. There are more examples here: www.php.net/str_replace
you helped me thnks sir
Glad to hear that, you're welcome
If you are going to learn PHP in 2022, This course is for you.
Did we cover ob_ stuff in detail yet? I feel like I'm missing something.
Do you have any specific question about it? We do use it again later in the course when we get to views
Bro as stated in last example If i take contents of a php file and inject it inside HTML file against a placeholder {{content}} inside body tag using the functions ob_start( ) and ob_get_clean( ) as you showed in the video in the last
this is my practice.php file
--------------------------------------------------
$x = 5;
function foo(): void
{
global $x;
echo "Hello $x";
}
foo(); Expected output -- Hello 5
Getting the output as --Hello
In the output I loose 5 .Does using a function as a string and injecting it in the layout makes it loose content in case of Global Scope? In rest of the cases I am getting expected output. Need your suggestion
Never use global, its not a good practice, most likely whats happening is that global $x is redefining variable without value.
@@ProgramWithGio I am practicing your entire PHP course video by video so this is the same example as you gave in video 1.23...:D Anyways I am in love with your PHP video series it has improved my knowledge a lot and has made me learn a lot more concepts...even some things I had never seen anywhere or heard of...Also shows exceptional effort you have put in your videos for including all sorts of content...:D
@@rxxt-sh1vj ah didn't realize you were using my example. In that video I was just showing it to illustrate an example, globals shouldn't be used in modern PHP, it's good to know what it is and how it works in case you are working on a legacy codebase.
Thanks alot, I'm really glad that you like my videos.
This is great, although maybe your `require_once` demo would be even more effective if you had kept the first call as `require`.
Thank you 🙌. It would have the same effect.
@@ProgramWithGio Yes exactly - some people though might think that you need to put it on all require calls for it to work, not just those after the first call. 🙂
Its amazing how php has default functionality when other languages like js and python would need entire frameworks to do this
Yea PHP is amazing & once you get to full stack frameworks like Laravel you'd be amazed how much functionality comes in built in
when using require two times in a same file i got redeclare error but didnt got it with require_once... but theres no error in ur side what might be the reason
require_once only includes it once, but with require, it would cause the error if you had a function in the file for example. If you are referring to the example at 2:15 there it's just an echo statement so nothing is being re-declared, if I had function, for example, it would cause an error.
Awesome video but "Don't worry about this now"---
Yes because we cover it later in the series.
This is where @blade directives can be parsed
Yes but we are not working with Laravel or blade
You didn't say anything about goto statements 😞
That was the point 😁. You don't need to know it, don't use it.
@@ProgramWithGio hahaha that’s good 😸
Thanks sir
Where are you from sir
You're welcome. I live in the U.S. but originally from country Georgia
@@ProgramWithGio I am very happy to get reply from you
Thanks for your support
@@prabu2778 You're welcome, thank you for the support as well
Wait wait wait, are you really saying that if I include a php file into another I automatically have access to the variables and functions and that it can also overwrite the variables I have declared in my original file? What kind of dumb implementation is this? Wtf php??? Am I missing something??
Yes that can be considered a good or bad depending on how you look at it. It comes in handy for templating engine implementations & there are some other use cases but in general yes it can be tricky to work with which is why I avoid having variables defined in files that are being included in other files. Once you start using OOP & proper templating this shouldn't be a concern
xD
🤔🧐