Complete PHP tutorial with project.

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this tutorial we are going to learn completely about php before telling what is php where php is used and what is the use of using php let's see an example and using this example we are going to understand what is php and what is the purpose of using php in our websites okay here i have a simple example everybody loves eating food and most of us love to order online and they love outside food okay so let's say today i have an holiday i am very bored of cooking so i ordered something and let me say in this example i have burger i have opened some food ordering website or food ordering app and i ordered for burger okay here i have ordered whichever company or whichever restaurant i have ordered they are going to receive this request and they are going to accept my request and they start preparing for the food what i ordered once my food is ready they will call the delivery boy and my food packet will be given to delivery boy and he is ready to deliver the food now he has come to my home he has delivered the packet i have received my food and i ate it i enjoyed a lot okay whatever i got i enjoyed it i ate that one and i am relaxed now once i eat that one i am back to my work now here if you see i have just taken some website online food ordering website i have ordered something whatever image i saw whatever food i saw i have ordered that one i have i have sent basically i have sent the request to that particular restaurant and that restaurant management will accept my request they will prepare my food and once it is ready they will give they will hand over that food to delivery boy and delivery boy will give the food to me okay and then delivery boy will come to my home and he will give the food to me okay i'll eat it and that's it okay that is my work now in this process whatever we have seen i am just ordering receiving and eating but the process involved in cooking okay whatever the process involved how much flour they have used how much salt they have used what materials they have used what food items they have used i am not aware of that because i don't know this process i have just ordered i have received i have eaten only that much work i have done but the process behind cooking okay whatever they are using what materials they are using i am not aware of this and i will not know this one because i am ordering online and this is the process i am unaware of so here in real world examples this is where php comes into play here if i just search in google if i show you an example here if i just write here fruits and if i search for fruits you can see here i will be getting more than okay this number i don't know but i'll be getting these many result in only 0.62 seconds basically i'm just sending one request that i want fruits data and that request will be sent to server server will process it and whatever data it matches it is going to return me and this going to return me only the result only the result it is going to return okay you can see only these many results i caught as an output but i don't know what process has been involved in server how the server is fetching the data how this google search engine works we don't know that one that is completely backend okay but google does not use this php i'm just taking an example google uses java python go node.js okay we have many other backend programming language that is being used by google so that is completely different we are not talking about what google uses we are just learning about php so this is an example okay whatever request you are sending that request will be received by server server will process that request and whatever data it matches it is going to return that as an output okay we don't know the process involved in this this is where php comes into play php is nothing but it is a server-side scripting language and it is used for back-end programming language because whatever request we are sending to server server will be sending the response in the form of html css and javascript okay the back-end process will not be involved and it will be hidden to everyone okay here i have an example okay here i have this picture and in this this client is nothing but our browser here i'm just searching something like i have search for fruits okay i have requested that one and in server it is going to send that request and server will do some process here process request and whatever result it matches it is going to fetch the result from the database and it is going to send the response in the form of plain html css and javascript once you are making your complete website then back-end programming is also very important using html we can design the structure using css we can give this filings to structure using javascript we can make our code interactive but using back-end programming language we can do lot of things we can add payment method we can add card shopping okay we can make complete website once we know back in programming language we are having many back-end programming language like we have node.js we have django we have flask but php if you are a beginner and if you want to start your first server-side scripting language then you can go with php because it is very easy to understand as a beginner it will be easy for you to grasp all the concepts related to back-end programming language and to understand what is programming language then php is great choice if you are planning to make your website in wordpress then you have to know the knowledge of php only then you will be able to work with wordpress okay so let's get started into the course and we are going to make one complete project once we learn all the concepts then we are going to make one website using php we will see how the back end works and also we are going to see mysql database how to fetch the data from the database and how to display that data inside our website okay so let's get started into the course before that i have already told you php is server side scripting language so php scripts will run only in servers so in our system we don't have server we have only browser to search the data and server will be sending the data for us so we have to install one local server inside the system so i am going to use xampp here okay and in that we are going to use apache now here you just have to type your exam exam download you are having here you can see here download xampp you just click on this first link and here you will be having options to download you can download for any operating system we have windows we have linux and we have os okay whichever operating system you are using you just have to click on download it will be downloaded in your system and then whatever permission it is asking you just have to permit that one and you have to install this zamp and you can see here zam it is an easy to install apache distribution containing it is going to contain maria db database php you can see php we have here and perl also it is going to use we just have to download and we have to install this one once we install this local server inside our system okay it's very easy you don't have to worry whichever you want you just select that one and it is going to download go to that particular download folder and install that one okay it's as simple as that you download and install this one and it will be ready to use okay you can also come to this link and here also you will be having the download option here inside this link also you can see here you are having this download option you can either download for windows linux or os okay you can choose whichever operating system you are using and here we are having the better definition zamp is the most popular php development environment because to run php script as a beginner we don't have to buy servers we can directly install this ramp and it is going to give us apache and also database php it is going to use okay so we can install this one and we can use this as a local server inside our system so that we can run our php script at php server side scripting language so it will be run on the inside servers now here i am having this zamp is completely free you don't have to pay anything to install xampp easy to install apache distribution and it is containing mariadb php and pull okay once you have done installing this one then you will be having this examp control panel you can see this is the zamp control panel and here we are having this apache mysql you don't have to worry about this filezilla mercury and tomcat we are not going to use this in this tutorial we are going to work only inside this apache and mysql apache will be acting as a local server to run our php script and mysql will be acting as the database okay once we start making our project then we are going to use this mysql database we are going to upload all the data in the backend and we are going to fetch the data and display in our website okay to run php script you just have to start this apache and wherever you have installed this zamp you can see wherever you have installed xampp you just have to come to that directory you can say i have installed in local c c directory here i have this zam folder i'll just click on this and here you will be having many files and folders for you it may not have but for me i am having and inside this you will be finding this htdocs folder you just have to click on this and here you will not be having much folders what i am having but this is the projects i have already created so you will not have many folders here inside this htdocs folder itself you have to create one new folder okay here i'm just going to create one new folder and inside this i'll just give the folder name as php tutorial okay here i have already created one folder i'll just delete this one okay here i'm having this folder php tutorial you can see here i'm having this php tutorial now inside this tutorial i'll be creating separate files and we are going to understand completely from the scratch what is php right click on this open with code now here you have to on this apache only then we will be able to run our php script inside our browser my vs code editor is getting started you can choose your favorite editor whichever you are comfortable with you can choose your editor okay you can use sublime you can use atom okay you can also use this vs code editor i personally recommend this one because it gives many functionalities and it is very user friendly and it's very easy to write code inside this vs code editor now here i am having this folder php tutorial now inside this first i'm just going to create one file i'll just give my file name as index.php okay whatever file you are creating if you want to write the code in php then the extension should be dot php okay if we are writing code only using html css and javascript for html we used to write index.html for css style.css and js dot js for javascript okay for php we have dot php extension now first we are going to start with syntax of php here you just have to open this one okay and this is the syntax of php and in between this we will be writing the entire php code now here let me just okay echo i'm going to explain you here i'll just write here hello world okay and every php script should end with semicolon or else we will be getting an error okay now once we are done with this i'll just copy this path wherever you have created we have created inside htdocs i have just copied the path and here i'm just going to paste the path now from here till htdocs i'll just remove this i'll just write here localhost localhost our folder name that is php tutorial and inside this i'm having index.php file once i click on enter you can say i got the output hello world okay this is our first php program if you are a beginner and if you have written this one then this is your first php program and congratulations for your first php program okay this is the syntax of php you have to write this one this echo is used to print the output inside a browser and every php script should end using semicolon php file should always have this dot php extension and to run php scripts we have to on our apache you can see i have already started apache and that's why i'm getting the output if i stop that one it is not going to work and also here you have to write this localhost because our server is localhost now this php tutorial whatever folder name you can give that one and you have to write the file name whichever file you are running that is nothing but index.php file okay this is the basics of php now let's start php now let's understand why we have to use php okay first of all it creates dynamic pages dynamic pages are nothing but okay you don't have to write the static code you don't have to hard code any values using php directly we can get the data from the database and we can display the data inside our website we don't have to hard code the entire page entire website we don't have to hard code so it is going to create beautiful dynamic pages and if you are working with database then we can modify the database we can add new database we can add tables inside the database we can do lot of stuff like if you are creating e-commerce website and if the user orders something that entire user details will be saved in one table and using that table using some keys we can access the data okay here php is used and you we can create many files we can open the files and we can read the files we can modify we can delete and also we can close the files using php okay mostly it is used for back-end programming so it can create beautiful dynamic pages now we have already seen here i'll just write the comment this is the syntax of php here what we have done this is the syntax and this is our first php code we have written okay here i have just written echo and this is used to print the data here i am having some text okay this is basically string we are going to see everything one by one and here every line of php should end with semicolon or else we are going to get some error and this file can contain html css and javascript as well and this echo is nothing but it is built-in function in php okay we have print and we have this echo we are going to see that one later but this is how we are going to write php and this is the syntax we are going to write the php like this now let's see about comments i'm just going to write one comment here mess comments you can see this double forward slash it is being used to comment php lines okay now whatever i'm writing here that will not be executed now if i just show you the output here if i just inspect this page i'll just refresh once and if i inspect this one you can see here inside this html file i'm having this body and here i am having this hello world okay anywhere php script is not printed and we i can't view php script here you can see that php syntax and echo whatever i have written that is not visible to me because this is backend programming and it will not be visible to anyone i'll just view page view page source and here if you see here you can see i'm having only this output okay i'm not having entire code okay whatever i have written in php this entire thing is not visible to me only this is visible okay only this in hello world is visible if i just write one html boiler plate i'll save this i'll refresh this one now when i view page you can see entire html is visible to me but here hello world that is php script only the output has been displayed to me whatever i have used the syntax comments whatever i have used that will not be visible to me okay it will not be visible to me as well as you but entire html is visible only php is not visible okay this is why we use php suppose you are writing very good algorithm and you don't want anybody to copy that one and you will write that algorithm in backend programming so that nobody copies it and nobody view your algorithm okay it is going to add lot more security to our code to our websites okay i'm just going to remove this html boilerplate now here this is called as comment in if you are using vs code editor if you click on control and forward slash it will comment this one again if you click it will uncomment this one okay here we have one more comment i'll just write here i'll just write here hash and this is also comment okay and this is also comment using this double forward slash or using this hash symbol we are going to comment in php okay you can use any of the comments and these are called as single line comments in php now we have multi-line comments now here you just have to write this forward slash hashtag symbol you just have to write some comments here and again you have to close like this okay this is called as multi-line comment and inside multiline we can add something okay we can add content here and we will be getting this output okay this entire thing will not be executed and this is called as multi-line comment and this is called a single line comment and also you can use this hash we have three types of declaring comment we have this single line this is two and we have this multi-line comment okay i'm just going to remove this okay this is all about comments and here i'm just going to write the comment comments okay we are done seeing the syntax we are done with comments now if you see this echo okay this is not case sensitive now if i just write here echo and if i print the output let me just write here hello world now this is not going to give me any error i'll just refresh this one now you can see again hello world will be printed now using php this is not going to detect the new line we have to give break line okay we have to give this break this html break tag only then we will be getting this break you can see that will come in next line because it is not going to detect new line and it will print side by side so once we give this break then all the lines will come one by one okay this echo and this echo will not give any error because it is case insensitive here okay this echo but like many functions we are having user defined functions we have if statement else statement that all are case sensitive so we have to be careful with that now next section we are going to learn about variables i'll just write one comment variables now variables are nothing but it is going to contain the data whatever if we want to initialize some data it will be acting as a container and that data will be stored suppose i have a bowl and inside that if i want to add some vegetables okay that ball is a container that is nothing but a variable and inside that i am adding vegetables okay that is nothing but a values so variable will hold whatever values we give that will hold that one and it is going to store that values okay it is just like a container to hold the data in php variables will always start with dollar symbol and variable names can have letters it can have underscore it cannot have numbers and it cannot have special characters as well variable names can either start with letters or underscore here i have started with dollar symbol here i'm just going to write my name let me just write here khan okay this is the variable and this i am initializing the value to my variable okay this variable is container now and this is holding the value kanam here okay this is string we are going to learn about that this data types we are going to see but this is how we are going to store the data okay but this is how we are going to store the data inside this variable now if i want to print this i just have to do echo and this entire variable i have to print that one i'll copy this and here i'm going to paste that one i'll save this i'll refresh this one now you can see i got output as khanam because i have not given br for this echo so i am getting this output in the same line if i give br i'll just copy this one and here i'm going to paste that one i'll save this i'll refresh this one now you can see i got the output as khanam here okay this is how we are going to create variables in php and this is how we are going to print variable should always start with letters or underscore it cannot start with number and these are case sensitive now here if i just write here my name like this if i write i'll just write here dollar symbol if i write here my name and if i just write here kahanam one two one two okay this both are completely different i'll just echo that one and this i want to print i'll just copy this and here i'm just going to paste that one i'll save this i'll refresh this one here you can see i got the output as kahanam1212 okay this is completely different variable and this is completely different variable because variables are case sensitive okay you should always remember this rules variable should always start with letters or underscore it cannot start with numbers variables are case sensitive both this my name and my name are different variables okay and we are going to get different output okay if i just write this entire same thing if i use your camel case my name i'll copy this one here i'm going to paste that one i'll save this this is also completely different because both are different okay this all are small letters and one n i have this capital so this is different this is not same and it is going to return me different output different result if you are aware of any other programming language in many programming languages we used to give the data type for the variables but in php we are not going to assign any data type because it is loosely tied language without declaring it is string or it is integer by using this by seeing this value it will understand this is string if i give here number if i give here 1 2 i'll save this i'll refresh this one now it is going to give me the output as one two you can see one two i got the output and it is automatically it is going to detect that it is a number okay if i give in double quotes or single quotes it is going to detect that it is a string and it is going to return with output based on whatever value i am having this is all about variables and how to declare variables now next we are going to see variable scope here i'm just going to comment i'll just write here variable scope now we have already seen that php variables can declare we can declare php variables anywhere in the script because we are not limited i can declare i'll just copy this one i'll just copy this and i can declare here as well i can declare wherever i want and i'll be getting the output and we have three types of scope first i'm just going to write first we have local scope then second we have global scope and third finally we have static scope okay we have this three types of scope and we are going to see one by one first we are going to see local scope what is local scope we are going to understand that one local scope is nothing but if i declare a variable inside functions functions you don't have to worry we are going to see that one if i create variable inside function and if i try to call that variable outside the function then i will be getting error because local variable life starts inside the function and it is going to die once my function is going to execute once i call the function okay that variable whatever i have declared inside the function i can't use outside the function okay we are going to see example of this now here i am just going to create one variable let me just create one variable i'll give my variable name as number 1 and inside this let me assign some value as 30 okay here i am having one variable now here let me just create one function and this is the syntax for creating function in php we just have to write function and here i am just going to write here testing testing okay this is the function name okay function function name and inside this let me just create one number two and here let me just give it 10. now to call this now to execute this function i have to call this function so we have to call this function we just have to write the function name and that function will be called now here i just want to print this variable i'll copy this variable and here i'm going to paste that one i want to print 10 here now in the same way i'll just copy this one here i'm calling this function now below this if i print number 2 i'll show you the output now you can see i'm getting this error undefined variable number two okay you can see in line 26 it's giving me an error inside this line 26 i'm having this echo number two which is not defined because this number two variable is created inside this function and if i try to call outside this function then i will be getting error because this is local scope and the variables declared inside the functions will be having local scope and they cannot be accessed outside the function okay this is all about local scope now we are going to see about global scope global scope now i'll just take the same example i'll just copy this one i'll comment this now here i'm going to paste that one now inside this okay this number one whatever i have declared that is global scope and i can access outside the function because it is declared outside the function i can directly access that output and i can get that output now instead of printing one if i just do here two and i'll just comment this function okay let it be i'll refresh this one now you can see i got the output as 10 and 30 here okay first i got the output as 10 then i got the output as 30. you can see first i am printing first i am calling this function and inside this function it is going to come and here i am having this number 2 and i am printing number 2 that is nothing but 10 then below this function i am having this echo statement that is number 1 and for number 1 i am having the value as 30 so that will be printed so first 10 will be printed and second 30 will be printed now if i call this function below this i can call as many as times i want you can see i'll save this one i'll refresh this one now you can see 10 10 10 10 10 30 now i'll just copy this and below this if i call i'll save this one now first 30 will be printed you can see first 30 will be printed then all 10 10 10 10 will be printed okay this is all about local scope the global scope variables can be accessed outside the function now next we are going to see about static scope i'll just write here static and this particle is nothing but suppose here okay in this example i'm just going to remove this now in this example if you notice this one once i have okay once this echo once i have done once i have called this function i am done with this okay now i can redeclare this variable i'll copy this one okay let me just copy this entire example i'll comment this one now here i'm just going to paste that one now i can re-declare this variable and it is not going to affect inside this function now below this i can just create like this and i can just give the output as 700 and here i want to print that one i'll copy this and here i'm going to paste that one i'll refresh this one now you can see i got the output at 700 i got the output as 30 i got the output as 10 and i got the output as okay let me just comment this entire things because it's disturbing i'll come into this one now if i show you the output you can see first i'm getting 30 then i'm getting 10 and then i'm getting 700 because first i'm printing number 1 which is having the output as 30 let me just write here break tax i'll save this i'll just save this one you just have to write here dot i'll refresh this now here i'm having 30 10 in the same way i'll just copy this one and here i'm going to paste that one i'll refresh this here you can see 30 10 and 700 okay this is basically i'm doing concatenation this is my variable name so to concatenate any string we just have to write here dot and inside single quarter double quotes we can just write whatever we want to print now this is the output we got now here if you see here i got the output for number 1 that is nothing but 30 here i am calling the function and this going inside the function and whatever variables it is having that is going to be printed and that is nothing but 10 and below this function i am re-declaring that one basically i am not re-declaring because as soon as this function ends okay this life of variable ends and we can use this variable again and again after this function is executed now here i am assigning the value of 700 and 700 will be printed but in some cases i want this value should not be deleted okay whatever value i'm having here that should not be deleted so for that we are going to use this particle here if i just write here static now this what it is going to do is it is not going to delete the variable once my function is getting executed this whatever i am having here this entire variable will not be deleted now if i just want to increase the number or decrease the number if i just write here number 2 i'll be writing here minus minus and here i'm just going to call this 3 4 times i'll save this i'll refresh this one you can see first i'm having this 10 inside this function okay let me just let me just comment let me just comment this one i'll just come into this and also this number 1 i'll save this i'll refresh this one you can see first i'm having 10 9 8 7 okay it is going to decrease the number by one if i don't give here starting i'll just remove this particle from here i'll save this i'll refresh this one now you can see i'm getting the output as 10 10 10 10 because each time once i call this function this entire function will be called and this life of the variable gets ended again once i call this function again it is going to come it is going to check it is having numbered as 10 it is going to print that one but as soon as we give static the life of the variable will not end and we can decrease the number here okay i am just decreasing by one if we give this minus minus we are going to see this one if we give this whatever value i'm having that is going to decrease by 1 10 minus 1 i'll be getting 9 here for this again 9 minus 1 i'll be getting 8 here 8 minus 1 i'll be getting 7 here you can see i got the output like that okay 10 9 8 7 so that is why we are going to use starting here starting keyword now let's move on to our next section i'll just comment this entire thing okay we have seen local scope okay the variables declared inside the function can be accessed only within that function okay global scope the variables can be accessed anywhere and we have the starting keyword if we don't want to end the life of the variable then we have the static scope okay now next we are going to see about data types okay there are many data types which are supported by php here i am just going to list down that one first we have string so again we have integer third we have float i'm just going to write this float and we have boolean i'll just write here boolean we have arrays we have objects okay these are data types supported by php and finally we have this null okay these are the data types which are supported by php now we are going to see one by one we have this string and string we have already seen that if i just write here language if i just create one variable let me just create one variable called language and inside this let me just write him php okay this is called a string and strings can be closed inside double quotes or i can just use here single quotes okay either one i can use i'll just use his single quotes now if i just write here language 1 and if i just write here language 2 and here let me just write here html okay these both are different and this is php and this is html this is enclosed in double quotes and this is enclosed in single quote okay you can use any one of this that is going to work and if i just print this echo and if i just print this language 1 i'll copy this one and here i'm going to paste that one and in the same way if i just want to print language 2 and also i'll just write here break pack to write any string we just have to write here dot and inside double quotes or single quotes i am just writing this br that is break i'll refresh this one now you can see i'm having this php and html okay strings can be enclosed either in single quotes or double quotes if you want to check the data type then we have this i just write here echo this we have this what dump okay now this is going to check the data type of this particular variable i'll just copy this one and here i'm going to paste that one i'll save this i'll refresh this one here you can see i'm having this string and four is nothing but the count of html okay the html letters html i'm having four letters so i'm having this four here that is nothing but string okay now this valve dump is going to return the data type in php what data type i am having and here how many lengths i am having that will be returned now if i just add here css now totally i am having seven letters i will save this i'll refresh this one you can see i'm having this seven letters here i'll just give it the break tag here i'll just copy this entire thing and here i'm going to paste that one i'll save this i'll refresh this one you can see that is string type and i am having seven letters inside this particular variable value okay this is all about strings now next we are going to see about integers i'll just write here integer and for this integer uh let me just create one variable i'll create variable as num and inside this i'll assign the value as 1 okay integers are nothing but it can have both negative and positive values but it cannot have any decimal numbers because it will come in floating point data type here if i just want to print that one i just write here num i'll save this i'll refresh this one here you can see i got the output as 1 now if i just write here minus 1 i'll save this i'll refresh this one i got the output as -1 it is going to take only integer values and decimal points will not be accepted in this now if i want to check the data type of that we have this one and just write here echo we just have to write this var dump and whatever variable name we are having we just have to write that one and save this i will refresh this one now you can see i am having this integer and value i am having here minus 1 okay it is going to return the value here it is going to return the length of the characters now here if i just write here 10 i'll just write here 1000 i'll save this i'll refresh this one you can see here it is returning the value whatever i have given and it is nothing but integer type but here it was returning whatever length i was having html that is for it was returning that one but inside integer it will return complete value whatever we have given inside the variable okay this is all about integer now next we are going to see about float float i will just create the same variable num and inside this let me just give here you can give here decimal points okay floating is nothing but after integer we can add decimal points if i want to print that one i'll copy this one here i'll just paste and uncomment this i'll refresh this here you can see i got the output as 1.223 ok this is nothing but float you can if you want to check the data type you just have to write the same thing and just copy this one here i'm going to paste i'll save this i'll refresh this one here you can see i got the data type as float and it is also going to return the value whatever i am having okay we have seen about strings integer and float now next we are going to see about boolean i will just come into this one boolean is nothing but it is going to return only two values that is nothing but true or false either zero or either one here i'm just going to create one variable i'll just write i'll just give the variable name as um is valid okay let me just write here let me just write here is valid and here i'll be writing here through okay this should not be enclosed in single quotes or double quotes okay if you close inside single quotes or double quotes then it is going to take as a string but this is boolean i'll just i'll just print that one i'll just do echo and here i just want to print this entire data i'll just paste that one here i'll save this i'll refresh this one now you can see it is going to return me the output as 1 because it is true true is going to return the output as 1 if i just write here false i will just write the correct spinning i'll write here false i will save this i'll refresh this one it's not going to return me anything because it is false for through it is going to return for false it is not going to return but we in boolean we have only two values true and false now if i just want to check the data type of this i'll just copy this one i'll be pasting that one i'll just copy this and this variable i'm going to paste that one i'll save this i'll refresh this one you can see i am getting the data type as boolean and the value is false here whatever i am having that value will be written if i write it through i'll save this i'll refresh this one you can see i'm getting this one as i output then i am having the data type boolean and here i am having the output as through okay this is how it is going to return the output and suppose if i just wrap this inside the single course or double quotes i'll save this and refresh this one now you can see the value is true because it is string and it's going to return me string and total number of characters inside that that is nothing but four okay for boolean values you should never enclose in single cores or double quotes okay you can see we got the data type string if i just remove this double quotes now now the data type will be boolean and i will be getting the output as boolean through and this is one is for true okay i'll just come into this one okay next we have arrays before moving to arrays let's see an example of null values null values is nothing but if we create one variable and if we don't assign any value to that variable that value that variable is not having any value so that value will be null here i'll just create one variable i'll just create one variable as fruits and inside this first let me just write here apple now if i want to print this one i'll be getting the output as apple naturally i'll just write here i'll just print this fruits i'll copy this i paste that one and i just want to check the data type of this i'll copy this one i'll be pasting that one and instead of this variable i want fruits i'll save this now if i show you the output you can see here i'll be getting apple that is nothing but string five digits okay five letters i'm having so i'll be getting five now here suppose if i just now if i just give here null i'll just write here fruits again and here i'm just going to give here null okay whatever value i'm having that i'm not going to initialize so i'm just giving here null now if i show you the output you can see the output whatever i got is null okay it is going to return me only the null that is the data type supported in php i'll just comment this one i'll refresh this now you can see here i am not having any data because this fruit is having this fruit is not having anything because i have reinitialized to null so here it is not going to print anything but using this wire dump we can get the data type of this and the data type is nothing but null okay this is all about null now next we are going to see about objects and then we will go into arrays and we are going to understand about arrays okay objects i have already created one video that is php oops and i have explained in detail about objects and classes here we are just going to see simple example what are objects and water classes object is nothing but it is a real instance of class so now what is class okay suppose if i just take an example of fruits okay this entire fruit is a class inside fruits we are having apple banana mango okay we are having many fruits and that is nothing but objects okay class can have properties like color name okay but each object a different object is having different color different name different taste okay because whatever properties my class is having all properties and methods of class can be accessed by each object inside fruits for each food we are having name we are having color we are having taste we are having with that all common properties i can give inside the class because i am just creating one template now i can create multiple objects if i create apple all the properties what i am having inside class that is name color width whatever i am having i can access that one and i can use that inside objects okay now we will see an example to learn about objects and classes in detail you have to learn about php oops and i have already uploaded the video on that you can refer that video if you want or you can search in youtube you will find lot of videos okay now here we are just going to see an example now here i'm just going to create class let me just create the class as fruits okay this is the syntax for creating classes here i'm just going to write class and my class name is nothing but fruits okay you have to write like this class class name and inside this i'm just going to create some properties properties are nothing but variables now here i'm just going to give this access modifier let me just give here name because each fruit will be having name and also i'll be giving one more property that is nothing but colors okay constructors and deconstructors i am not going to use in this example because it will be very difficult for you to understand before knowing how to set the values and how to get the values okay so we are just going to see the simple example and before that i am just going to comment this null example here i have just created class and inside this i am just creating some properties and properties are nothing but variables inside class now here i'll just create one function and functions are nothing but methods here i'm just going to write here access modifier if we don't give public then also by default it is going to be public function and here i'm just going to write here set name okay you can give any function name here i just want to set the name okay whatever i am having here that i want to set that one now inside this i just want to set so i'll be writing this keyword okay this keyword is nothing but it is going to tell me that particular object whatever i have created suppose if i create apple for that particular apple this is going to fetch the data i want to fetch name so i'll be writing like this and i'll just write here name variable and i want to once i set this one i have to get also so i'll be writing this public i'll be writing this function keyword and i want to send now i want to get the name i'll just write here get name now inside this get name i'm just returning whatever value i got i'm just returning that one and value whatever i got it's been stored inside this i'll be returning that one okay this is all about classes we are just creating one class and inside class we are passing properties and methods now this properties and this is just a template now this properties and methods can be accessed by objects and we can create multiple objects using class suppose if i just create here apple and this is the syntax for creating objects and i'm just writing object name here okay we have to write dollar symbol here because we are creating variables now here we just have to write this new keyword and whatever class name we are having we just have to write that one i'll paste that one and we have to close in parenthesis okay this is how we are going to create objects we have to use this new keyword class name and whatever object we are creating that is nothing but apple now i have created object for apple now i have to set the name for this now to set the name we just have to write like this i'll just copy this apple i'll paste that one i'll just write this arrow symbol and inside this i just have to call this function set name and here i'm going to paste that one and inside this i'm having one parameter here i'm just writing here uh apple because i'm creating apple object so i'll just write that one now i have to get that one so i'll be writing apple object now here i have to get this one and inside this get name i'm returning this name whatever i am having here that i am returning so i will be getting this output now if i refresh this one now here i am getting this output get name okay i have to close in a paranthesis now if i just show you the output i will not be getting any output because i have not printed anything but if i as soon as i give this echo i'll save this i'll refresh this one you can see i got the output as apple okay this is how we are going to create classes and we are going to create objects and this data type is also supported in php and once you learn advanced topic that is php then you will understand this in more better way and in more advanced level ok here i am just setting the name of that particular object and here i am getting that one now if i want to create another object i'll copy this one and here i'm going to paste that one instead of apple let me just write here mango and here also i'll be writing mango i'll just copy this i'll be writing it here and also here i'll save this i'll refresh this one here you can see i got apple and mango i can create multiple objects using this class template okay this is the only template and these are the real instance of that class okay instance of class okay this is all about objects now next we are going to see about arrays here i am having this comment arrays for arrays i'll be creating separate files so that we can learn functions of arrays as well okay here i'm just going to create one new file i'll just give here two i'll be giving here array array.php always php file should be having dot php extension now in this file first i'm writing i'll just save this file i will be closing this index.php now inside this array.php first i'll be writing syntax of php like this you have to write now inside this i'll just write the comment i'll be writing arrays now arrays are nothing but in single variable we can store multiple values okay they are used to store multiple values in a single variable okay here inside index.php i have created variables you can see i have created variables here and in this variables i can store i can assign only one value here okay like this i can assign i cannot assign multiple values in single variable but using arrays we can assign multiple values now here if i just create one variable i'll be creating one variable colors and this is the syntax you just have to write this array and inside parenthesis you can write multiple values separated using comma and enclosed in single quotes or double quotes here i'll be writing blue i'll just separate using comma i'll be writing green and here i'll just write here hello you can see in single variable itself i can store multiple values using this array you just have to write the variable name array open parenthesis and inside this parenthesis you can write multiple values now to get this data if i just echo and here if i just write here colors colors and index number will start from 0 this will be having index number 0 this will be having index number 1 and this will be having index number 2. now if i want to print blue color i just have to write here 0 i'll save this now i'll just copy this path and here inside new tab i'll just paste the path and from here i'm just going to remove till hd docs and here i'll just write local host i'll enter now you can see i got the output as blue okay this is how we are going to get the data using index numbers now if i want to print the entire array if i just write here echo and if i write here colors okay i'll be getting warning i'll save this i'll be telling you why we are getting this notice you can see i'll be getting this notice array to string conversion and i'm getting the output as array but i want this entire thing as my output so for that we are going to see for loop but before that we are having this one more built-in function that is nothing but print r and inside this i'll be giving this array name i'll save this i'll refresh this one okay i'll just comment this so that i will not get any notice now if i refresh this one you can see i got the output as array and inside this at zeroth index i'm having blue color at first index i'm having green color and at second index i'm having yellow color okay this is how we are going to print arrays okay arrays this is the syntax of arrays and this is how we are going to pass index number and we are going to get the data and using this printer we are getting the entire data okay now we are having three types of arrays first we are going to write indexed arrays first we will see that one indexed array indexed array is nothing but whatever we have given here that is called as indexed array we can access the variables we can access the values of the variables using index number if i want to get only the values suppose here if i want to get only blue green and yellow instead of this output if i want to get blue green and yellow then we are going to loop that array inside for loop till now we have not seen about loops but in this example i'll be explaining you what is loops as well and later in later session we are going to see in detail now inside this indexed array first i'm having this colors okay here you can see i'm having this colors array i'll just comment this entire thing this entire thing i'll be commenting i'll just copy this and here i'm going to paste that one now to find the length of the array i'll just create one variable i'll just write here colors length and inside this we just have to write here count and which array we want to count i want to count this array i'll copy this one and here i'm going to paste that one now if i echo if i echo this array length i'll copy this here i'm going to paste that one i'll save this now if i refresh this one you can see i got the output as 3 this is going to give me the number of values present inside array now using this colors length i will be looping through each a and i will be getting the output now here i'll just write here for loop okay you don't have to worry about for loop i'm just writing this for loop and inside this it will take three things first it is going to take the initialization i'll just write here x is equal to zero you can give any variable here and i'm just giving another condition if my x is less than this colors.length i'll copy this one and here i'm going to paste because less than or equal to if we give then x will be 0 1 2 and 3 okay i don't want 0 1 2 3 because my colors length is 3 so x will be 0 1 2 and 3 if i give less than then 0 1 and 2 because here index number is 0 1 and 2 totally i want only three values and my index number starts from zero so it should be less than three so i'm just giving this condition first my x is zero that is initialization then i'm giving condition inside for loop and next i just want to increase the value of x for each loop i just want to increase the value of x so i'm just giving here x plus plus now inside this i just want to print this array i'll just copy this one echo and here i'm going to paste that one and also i'll be giving one break okay so that all the output will come in next line i'll just give here break i'll save this i'll refresh this one okay now here i'm getting this notice array to string conversion on line 14 okay now i want to print this in there okay i have already looped through this so i have to get instead of index number instead of hard coding the index number i just have to write here dollar x so that first my index number will be 0 it will come inside for loop colors of 0 will be blue then again my x is incrementing here it will you know x is 1 it will checks 1 is less than or 1 is less than 3 yes it is true it will come inside the loop and now colors of 1 will be green ok same way it is going to increase again it will be 2 it will check the condition 2 is greater than 3 2 is less than 3 yes it is so it will come inside this loop and it will print yellow okay colors of 2 is a low again it will increase the value of x it will check the condition if 3 is less than 3 it is false so it will come out of the for loop here i'll save this now if i refresh this one that this entire notice will go and i will be getting the output as you can see blue green and yellow okay this is how we are going to get the output i'll just comment this length now now if i show you you can see blue green and in low if i add some more values here if i just add here white and let me add black i'll save this now if i refresh this one you can see white and black has been added here okay this is how we are going to loop through arrays and this is called as indexed array okay this is first type of array and that is nothing but indexed array next we are going to see about associative array i'll just write here associative associative array and this array is nothing but it will be having key value paste now we are going to see the syntax of this now let me just create one variable data and inside this i'll just create array and here this is the syntax for inside this i'm just going to write key value paste now here let me just write here khanom and kanam is i'll be writing here computer science csu computer science students basically separated using comma i be writing another name i'll just write here riya and rhea is a mechanical student okay i'm just passing this is the key whatever i'm having on my left side that will be key you just have to write this equal to and this arrow symbol and next we have this value okay for khanam i'm having the value as cac and for d i am having the value as make now here let me just write here subject instead of data let me just write a subject for khanam the subject is csc and for rhea the subject is mechanical i am just writing that one and i am assigning that cse to khanam and mechanical to riya hanam is nothing but key and cac is nothing but value now to get this output we are not going to see we are not going to use index number we are going to pass this key and we will be getting the output now if i just write here echo i have to write array array name i'll just write here subject and inside this paranthesis i am passing this khanom i'll just copy this one and here inside double quotes i'll just paste that one i'll save this and before that i'm just going to comment this indexed array i'll just copy and here i'm just going to close that one i'll come into that one i'll save this now if i refresh this one you can see i got the output as cac okay for khanom the value is csc that will be printed to me now if i want to get the output of fria i'll just copy the and here i'm going to paste i'll save this i'll refresh this one you you can say i got the output as mechanical here i'll just copy this break tag and here i'm going to paste i'll refresh this you can see csc and mechanical for khanam and ria okay this is how we are going to print the output of associative array if we want to loop through each array we have another loop method that is nothing but for each okay now using this for each loop this is the syntax for forage okay i'll just give my array name here i'll just copy this one and here i'm going to paste array name you just have to write the array name as i will i'll just create one variable and this variable will be for my key i'll be giving this arrow symbol and i'll be writing here value ok now this value is nothing but whatever value i am having inside my array that value okay this is my array name as you have to write as and inside this x whatever values i'm having that will be stored and inside this value whatever value i'm having that will be stored okay you can give any variables you can give any variable names here but this is our array name now i want to print this one so i'll just write here echo echo i'll let me just write here key my key is equal to now i have to print this x now to print this x we just have to concatenate like this x now again i have to print this value okay i'll be writing here value i'll just write here value is equal to again i have to concatenate this value whatever i am having here i'll just copy this one i'll just copy this and here i'm going to paste that one and also i'll just copy this break tag from here i'll be pasting it here i'll just comment this echo i'll save this i'll refresh this one now you can see key is equal to khanam value is equal to cac key is equal to and value is equal to mechanical okay this is how we are going to loop through associative arrays and we will be getting the output okay this key okay this is string so we have to enclose in single cores and we are concatenating we want this value so dot x we just have to concatenate so we are writing this dot and whatever value i want i am just writing that one again i want this value so dot again this in string again i want this one so dot and this one okay this variable should not be enclosed in single quotes or double quotes or else it will be taken as a string but rest all should be enclosed in single quotes or double quotes okay this is how we are going to loop through associative arrays and we will be getting the output if i add some more data here suppose i will just separate using comma i'll be giving here sigma and sima is a ece student i'll just enclose in double quotes i'll save this i'll refresh this one now you can see key is seema and value is esc okay this is all about associative arrays associative arrays will be having key value page and using that we will be getting the output now next we are having multi-dimensional array i'll just write the comment here multi-dimensional array multi-dimensional arrays uh array which is containing more than one arrays that is called as multi-dimensional array okay here we are going to see an example here let me just write here the same example let me just write here colors and inside this i'll just write the syntax of array and inside this array i'll be creating more arrays i'll just write here array and inside this i'll be passing values i'll just give you a red color and let current i have 11 pens okay i'm just writing that one i'll just separate using comma and again i'll be writing this array i'll just write here blue color and blue i am having around 10 pins next i'll just write one more array i'll just write here inside this i'll be writing here orange and let me just write here 80 okay now you can see this array is having more arrays this is first array this is second array and this is third array and for this first array i will be having the index number 0 for this will be having the index number 1 and for this i will be having index number 2 okay but inside this array this will be index number 0 and this will be index number 1 this will be index 0 and this will be 1 again this will be 0 and this will be 1 ok inside this array there are multiple arrays and inside each array i'll be having index number so now this will be first array and this whatever i am having in five parenthesis that will be my values for this arrays now for this array this will be the values now to access this one i'll just write here echo and i'll be writing my array name that is nothing but colors and inside this okay now this is multi-dimensional array array inside array so now this is my first array so i want to access this that is 0th index of this array i'll be writing a 0th index and i want the output as 11 so this is 0th index and this is first index of this array so i'll be writing here 1 i'll save this i'll come here i'll refresh this one okay undefined variable colors i'll just write here color okay let me just write here colors i'll save this i'll refresh this one now you can see i got the output as 11 okay now if i want to get the output of uh i want the output as blue then for this array this index number is one okay now this entire thing is zeroth index and this is index number one so in first square bracket i'll be writing index number 1 and for this array blue is in 0th index so here i'll be writing 0 i'll save this i'll refresh this one you can see i got the output as blue now if i want 80 now for this array this index number is 2 so here i'll be writing 2 and index number of 80 is 1 i'll just write here 1 i'll save this i'll refresh this one you can see i got the output as 80. okay this is how we are going to access multi-dimensional array to loop now we will see how to loop through this array now here i'll be writing for loop again i'll just write here for loop and inside this first i'll just give a row number okay row i'll just give you a 0 you can give any variable name i'm just giving here row and i'll just separate using comma and i'll just write here row i'll just write the condition as a 3 okay i'm not finding the length i'm just writing the condition directly i'm just writing the condition if you want you can find the length like this using count and array name i'll just separate using comma and each time i want to increase the value of row i'll just write here row plus plus now inside this first i want to print the row number so i'll just write here i'll just write here echo and here let me just write here row number and i want to print the row number so i have to concatenate that one i'll just write here dot row now this is multi-dimensional array so array inside array so this is for my row and now i have to find the columns so i'll just write here another for loop and inside this let me just write here column first i'll just initialize the value as 0 and here i'll just give the condition call is less than 3 my column is less than 3 and also i'll just give i'll increase the value of column now here inside this i want to print the column number and row number whatever value i'm having that i want to print so i'll just write here echo i'll be writing my array name that is nothing but colors and inside this first i want to get the row number whatever i got from here that i'm accessing suppose first i'm getting 0 so 0 will be accessed here and next i'm just going to write here column i'll just write here call okay now i'll just explain you this one from here i am getting the row number first my row number is 0 it will be printed my row number is 0 here so it will come inside this loop my column is 0 now so i will be getting 0 of 0 that is nothing but this 0 and inside this this will be zero so first i will be getting red color okay now again the value of column will be increased it will be increased to one my row is zero itself so again zero and one again i'll come here zero and inside this i'm having this one it will print red and 11 okay let's check the output i'll refresh this one you can see i'm getting the output as undefined offset to on line 37 okay first data i am getting 80 row number and 0 8 i am getting but here i am getting undefined offset 2 okay let me just check here okay instead of this 2 i just in 3 i just have to give here 2 for row number row will be like this row is nothing but in horizontal row and column is in vertical row i'll just tell you i'll just open paint now here if i just tell you okay this is my row first row second row and this will be my third row i'll just increase this one now inside this first row first i'm having here red color okay here i'm having value red and here i'm having that value 10 again blue and some value 10 again something and something okay this vertical row is called as column this entire thing is called column okay i'm having totally two columns here and totally i'm having three rows here for red color blue color and for another color so column is vertical and row is horizontal so for column i have to give here two because i'm having two columns so 0 and 1 it will check for 2 conditions and rows i am having totally 3 so 0 1 2 so totally i have to give here 3 and here i have to give the column as 2 and also i am just going to give here break i'll save this i'll refresh this one okay and i'm just going to come into this i'll save this i'll refresh this one you can see first my row number is 0 okay first my row number is 0 the output is red and 1 okay and also over here i'll just give one break i'll just copy this one and here i'm just going to paste that one i'll save this i'll refresh this one you can see row number zero i'm having red and 11 okay that is nothing but this red whatever i'm having here red and 11 is in my row number zero that is first horizontal line on my first row i'm on second row i'm having this blue and 10 so i'll be getting the output as blue and 10 okay that will be my row number one and finally on row number two i'm having the output as orange and 80 okay this is how we are going to look through multi-dimensional array first we are going to find the row number so that we can get the access to this column number and using this row number we are going to print this one tray of 0 array of 1 and array of 2 and inside this array i am having this 0 1 0 1 and 0 1 ok this is how we are going to get the output you can see row number zero red and eleven row number one blue and ten and row number two orange and eighty okay this is how we are going to loop through multi-dimensional array okay now next we are going to see some functions in arrays here i'm just going to comment this entire thing i'll save this now below this i'll just write one comment i'll be writing here functions in php functions in arrays i'll just comment this one i'll just comment this now below this first we will see the first method that is nothing but sort now we are going to see first function in array that is nothing but sort and this is going to sort the numbers or alphabets in ascending order here i'll just write one example i'll just create one variable fruits and inside this i'll be creating array and here let me just write here apple and here i'll write mango and next i'm just going to write here pineapple and finally i'll just write here banana now here i want to sort this one salt and inside this i'll be passing this array name okay whatever you are having this one this fruits you just have to write inside this sort function now if i just write here echo and if i do fruits okay you can see i'll be getting warning that array cannot be okay you can see this one i'll be getting some notice here array to string conversion on line 48 okay so for arrays we should always use this print r but while printing the index number of array we can use echo but while giving this entire array we have to give this print r i'll save this and this is used for arrays now if i refresh this one you can see first i got apple banana mango and pineapple okay it's been sorted in ascending order you can see first apple banana but here i have apple mango pineapple and banana but in my output it is sorted in ascending order and they are having their particular index number okay this is our first function that is nothing but sort now i'll just comment this one and below this i'll be writing the next function that is nothing but r sort now this function is going to sort array in descending order i'll just copy the same example and here i'm going to paste that one i'll just uncomment this entire three lines now instead of sort i'll just write here r sort i'll save this i'll refresh this one now you can see first i'm getting pineapple mango apple and banana it's been sorted in descending order first i'll be getting pineapple mango banana and apple for this example we got first as apple i'll save this i'll refresh this one you can see first am getting apple banana mango and pineapple and for this pineapple mango banana and apple so this will sort in ascending order and this will sort in descending order i will just comment this one and also i will be commenting this one now we are going to see another function that is nothing but a sort now we have already seen about associative arrays associative arrays are nothing but key value pairs and this function is used there to sort the values in ascending order we are going to use this a sort function now here let me just copy this associative arrays example i'll just come here i'll copy this entire thing i'll just copy this one and here i'll be pasting that one okay this is associative very inside this i'm having this key value paste now whatever value i am having here that will be sorted in ascending order this this and this first i have cac then mechanical then ece so in my output first i'll be getting cac then ece then mechanical now below this i'll just write this one i'll just write here a sort a sort function and inside this i'll be writing this subject array now if i want to print that one i just have to use this print r print as you can see i have this suggestion and inside this i'll be passing this subject i'll save this i'll refresh this one now you can see first i'm getting cac second i'm getting ec and third i'm getting mechanical okay this is going to sort values in ascending order i'll just comment this one next we have k sort and now this k sort is going to sort this keys whatever i am having this keys it is going to sort in ascending order i'll just copy the same example and here i'm going to paste that one i'll just uncomment this entire thing and instead of this a sort i'll just give here k sort okay now this k sort is getting sorted in descending order so you can see first i'll be getting here riya second i'll be getting sema and third i'll be getting khanam okay next we have another function that is nothing but a r sort i'll just copy this entire same thing and here i'm going to paste that one and instead of this i'll just write here a r sort i'll just uncomment this and here i'll be writing a r sort i'll save this i'll refresh this one now you can see i'll be getting the same output okay whatever i was having for this one okay for whatever i was having for this one that output i am getting a r sort and this is going to sort the values in descending order so first i am getting mechanical ece and cse okay let me just print all the outputs here i'll just uncomment this i'll just uncomment this entire thing and also i'll be uncommenting this entire thing not this one r sort i'll just uncomment this and finally i'll just uncomment this and below this i'll just write here echo and i'll be writing this br tag so that i'll be getting output in next lines i'll just copy this br tag and here i'll be pasting that one and also here i'll be pasting that one and finally i'll just paste that one here i'll save this i'll refresh this one now you can see okay let me just delete this one let me just comment this r sort i'll save this i'll refresh this one now you can see the output for this and this i'm getting the same output because this this k sort it is going to sort keys in ascending order and this is going to sort values in descending order now in the same way i'll just copy this one i'll just paste that one here and now this kr sort is going to sort keys in descending order i'll just write here kr sort i'll save this i refresh this one now you can see here this last output and first output will be same because this is going to sort this keys in descending order first i am having khanam then i am having seema and finally i am having riya okay this is how it is going to work and we are having this arrays function we are having sort function this is going to sort in ascending order this r sort is going to sort in descending order this a sort is used for associative arrays and this is going to sort values in ascending order and this k sort is going to sort the keys in ascending order this ar sort is going to sort the values in descending order this k r sort is used to sort the keys in descending order okay this is all about arrays we are we have three types of arrays indexed array associative arrays and multi-dimensional arrays and these are functions in addis to find the length of array we have this count function you can see here we have written somewhere we have this count we have this count function and this is going to return the length of the array okay that's all about arrays next we are going to see some of the string functions now here i'll be creating one file i'll just give my file name as three strings dot php now inside this file first i'll be writing this php syntax that is php boilerplate now inside this we are going to see some string functions i'll just write the comment as string functions now below this first we are going to see the first function that is nothing but string length now this function is going to return the length of the string how many characters are present inside that it is going to return that one now here let me just create one variable i will be writing here language and here i'll just write here hypertext preprocessor okay this is the full form of php hypertext preprocessor now here i'm just going to use this string length and i will be getting the length here let me just write here str length and inside this i'll be passing this length i'll just copy this one entire thing and here i'll be pasting that one and here i'll just store this value inside separate variable i'll just write here length now below this i just want to print that one i'll just write here echo dollar length i'll save this and here i'll just copy this file path and inside this new tab i'm just going to paste the path and i'll be removing till ht docs you can see i'll just remove till ht docs and here i'll just write here local host enter and now if you see i'll be getting the output as 22. now if i count okay let me just give a small ah small word i'll just write here php i'll save this i'll refresh this one now you can see i got the output as three here i will just do control z now if we count one two three four five six seven eight nine ten eleven okay it is going to take the space as well to welcome totally 22 characters i'm having here so the output will be 22 it is going to count the space as well now here i am having one two three four five six seven eight totally nine letters i am having here i'll save this now if i refresh this you can say i got the output as nine if i just give here two spaces i'll save this i'll refresh this one you can see i got the output as 11 okay this is how it is going to work it is going to return the length of the word inside this one this is our first function that is string length now below this we are going to see another function that is nothing but word counting counting words okay how many words i am having inside string that we are going to see here i'll just copy the same example i'll just paste that one here i'll uncomment this entire thing now here hypertext i'll be writing here preprocessor and here i'll just write that function string word count you just have to write this one and it is going to count the number of words i have two words i'll save this i'll refresh this one you can see i got total two words okay this is going to return the number of words present inside string okay these functions are very useful when we are designing big program then this small small functions will be very useful so you have to know this basic functions i'll just copy this function from here and here i'll just paste that one okay this is our second function string word count now next we are having string reverse i'll just write a string reverse now this function is going to reverse the entire string i'll copy this one and here i'm just going to paste that one i'll save this and here instead of this i'll just write here string reverse i'll just write here reverse i'll save this i'll refresh this one now you can see this entire okay uncaught error call to undefined string reverse okay we should not give this underscore here i'll save this i'll refresh this one now you can see entire text is reversed okay entire text has been reversed first i am having here hyper text then preprocessor okay this is how we are going to reverse this one now next we have another function that is nothing but string position i'll just comment this one and here i'll be writing string position i'll just copy this one and here i'm going to paste that one now this string position is going to search for the particular word or particular text inside the string and it is going to return the index number of the first match i'll copy this and here i'll be pasting that one now here i'm having total two preprocessor now here i'll just write his string position now inside this language variable i want to find preprocessor i'll just copy this one and here i'm going to paste that one inside double quotes i'll save this i'll refresh this one now you can see it is going to return me 10 because it is going to return the first index number of the first match 1 2 3 4 5 seven eight nine total ten letters i'm having one space so it is going to return me the tenth number and this is the first match here also i'm having preprocessor but it is not going to consider that one it is going to consider the first match and it will return the output as 10 okay i'll just come into this entire thing it is just going to return the first position now this is all about string functions now next we are going to see some of the php numbers and later we are going to see some math functions now here i'll be creating one more file i'll just give my file name as numbers numbers.php and inside this file we are going to see some of the number functions here i'll be writing this php syntax now inside this first i'll just create one variable i'll just give my variable name as number just assign the value as 10. now we are going to see some of the number functions and here i just want to print that one i'll be writing this echo first we will see what is this is okay now this is in function is going to check whether this number whatever i am passing inside that one whether it is integer or not okay if it is integer it is going to return me through if it is not integer then it will return me false i'll just copy this file path and here i'll be pasting that one and from here i'm just going to remove this now i got the output as one if i just do var dump okay let me just give that one now here instead of this let me just give here value so that we will be getting the correct value i'll just write here var dump and save this i will refresh this one now you can see i'm getting the value as boolean through now if i just give here some floating numbers i'll save this i'll refresh this one you can see i got the output as false if i give a string i'll just give i will make it as string now this is string i'll save this i'll refresh this one again i'm getting the value as false okay now this function is going to check whether the number is integer or not okay in the same way we are having another function that is float i'll just write here float fl o80 i'll save this now this is string so if i refresh this one i'll be getting the output as false as soon as i remove this double quotes i'll come here i'll be removing this double quotes from here i'll save this i'll refresh this one now you can see i got the output as true okay now this function is going to check whether the number given inside this parenthesis is floating point or not now next we are going to see is numeric i'll save this i'll refresh this one okay i'll just give the proper spelling i'll just write here is numeric i'll save this i'll refresh this one you can see i'm getting the value as boolean through whether it is floating point or integer i'll be getting that i'll just get the output as boolean through you can see again i'm getting boolean through suppose if i just add some letters here i'll save this i'll refresh this one you can see i'm getting this error rr is not defined if i just enclose in uh single quotes or double quotes i'll save this one i'll refresh this now i'll be getting boolean false okay it is going to take both integer and floating as through but if we give string then it is going to give me false okay these are some number functions okay i'm just going to comment this one and here i'll just write here we have seen about is in we have seen about is float and finally we have seen about is numeric okay we have seen about three functions we have some more functions like we have is finite is infinite okay you don't have to learn about that but these are some important number functions in php now we are going to see casting i'll just write here heading i'll just write here casting and below this suppose i'm just having one variable i'll just give my variable as 10.3 okay i'm just giving the float value to x now if i just print this one dollar x and also if i just show you the data type of this one where dump and inside this i'll be passing this dollar x i'll save this now i'll refresh this one you can see i'm getting that value and i'm getting the data type as float let me just give one break here i'll just write here echo and i'll be adding this break i'll save this i'll refresh this one you can see value i'm getting 10.333 and float i am getting here now if i want to convert this float to integer then we can do casting here i'm just going to create one variable i'll just write here into data okay let me just write here int number and here we just have to write like this i will be writing into number and we have to convert into integer so i will be writing here integer and here whatever variable which is holding the float value we just have to write that one i'll just write that one here i'll save this and now if i show you the output i'll just write here echo and i'll be writing this number uh not number it's ink number and below this i'll just write the same thing i'll just copy this one and here i'll be pasting that one and also i'll just copy this break and here i'll be pasting that one i'll save this i'll refresh this one now you can see i'm getting the data type as 10.33 and here i'm getting the data type as float but here i am getting the value as 10 only 10 i am getting now instead of this x i'll just copy this and here i'm going to paste that one i'll save this i'll just copy this one and below this i'm going to break i'll save this and now if i refresh this one you can see first it is float then i have casted that one and i have converted to integer okay i'm just i'm just writing this one in i have to convert into int and whatever variable i want to convert that variable we have to pass here and if you print that one we will be getting the data type and also we will be getting the value this is about casting float to integer we can also cast to string suppose for this variable let me just write here hello hello world i'll save this and now this value is going to print me hello world and for this data type i'll be getting the output as string now here i'm just converting that one let me just write here okay let it be inked and i'm just converting it to ink and here i'm printing that one now if i show you the output i'll refresh this first you can see i got the output as hello world next i'm getting here string and i'm getting this one and integer i'm getting here 0 because this is alphabets okay inside integer we cannot give alpha bits so let me just give here one two one two now this is string i'll save this i'll refresh this one you can see i got the output here first i am printing that one and it is nothing but string and second it is converted to integer and the data type is integer okay we are just casting string to integer okay this will be very useful when we are making forms and also when we are making projects then this casting method will be very very useful now next we are going to see math functions i'll just write one comment i'll be writing here math functions and inside this we are going to see some of the math functions first we have this pi function i'll just write here echo and you just have to write here pi okay you don't have to pass anything inside this one pi value we already know 3.1.4 something and that will be printed and also i'm just going to comment this entire thing i'll save this and if i refresh this one you can see i'll be getting this pi value okay you just have to write this pi and it is going to return the output we have another math functions i'll just comment this one now here i'll be writing this echo we have min function inside this i'm just going to write here min and here let me just write here 1 3 0 4 okay let me write here 4 6 okay let me just write i'll save this i'll refresh this one you can see i'll be getting the output as 0 because minimum value is 0 here this function is going to return the minimum now here i'll just copy the same thing and here instead of min i'll just write here max i'll save this i'll come into this one now if i show you the output you can see i got the output as 6 because my maximum value is 6 here i'll just comment this one and next we are having absolute i'll just write here echo and inside this i'll be writing this abs abs is the short form of absolute and inside this i'll just pass some negative number i'll save this i will refresh this one now you can see it is going to return mean positive number whatever negative number i am passing that will be converted to positive number and that will be returned as an output okay next we have square root i'll just write here echo and inside this we are going to write here square root and this function is going to return the root of that particular element now suppose if i just write here 64 64 is root of 8 i'll just refresh this one now you can see i got the output as 8 okay this is square root function next we are having round function echo and inside this i'll just write here round let me just write here 1.9 i'll save this i'll refresh this one see you can see it has been rounded to 2. now if i just write here 1.2 i'll refresh this one is it has been rounded to 1. now next we have random function i'll just write here echo for random you just have to write like this r a nd and i'll just close this one we don't have to pass any values as of now i'll refresh this now you can see it is going to return me some random number again if i refresh again it is going to return me some random numbers okay this random function will be very useful in guessing game now if you want on this number should not be so long okay it's very lengthy i don't want this number suppose if i want the number should be printed from specific range so inside this you can pass parameters suppose i want from 20 and 200 in between this i want all the numbers should be printed i'll save this i'll refresh this one you can see in between 20 to 200 only i'll be getting this output okay this is all about math functions okay we are having pi min max absolute square root round and random now next we are going to see php constants i'll just write i'll just create one more file i'll just give my file name as constants constants.php now inside this file first i'll be writing this php syntax and we are going to see the syntax of constants here i'll just write here syntax syntax of constants now here below this first i'll be writing the syntax we just have to write here define and inside this first we will be giving the name of the variable second we will be giving the value and third finally we will be giving whether it is case sensitive or not so let me just write here case insensitive we just have to write here define inside parentheses we have to write the name of the variable in php we have already seen that variable should be having dollar symbol but in constant variable should not have dollar symbol either it can start with underscore or letters here i am having the value for that particular variable and here i am having whether it is case insensitive or not default is false if we give here true then case it should whatever name i have given that should be passed okay let's see an example and then we will understand in more better way now here i just write here define and inside this i'm just going to create one variable i'll just give my variable name as name and inside this i'll just pass the value that is khanam now i want to print a name so we just have to write here echo and here i'll be writing name whatever i'm having here i just have to write that one i'll save this i'll just copy this file path and here i'm going to paste the file path i'll just remove this from here i'll just write here localhost i'll enter now you can see i got the output as khanam now in place of capital letters if i just give here name i'll save this i'll refresh this one now you can see i'll be getting this warning use of undefined constant name assumed name this will throw an error okay now this is going to generate error because by default it is false now if i just give it through and save this i will refresh this one now you can see i'll be getting the output as khanna okay now this through means i can either use this okay it will not be case sensitive it is going to be case insensitive so by default it is going to be false so whatever i have used that should be same as soon as you give here through whatever name i am having if i give in small letters then also it is going to work and it is going to generate output for me this is variable in constant we have to declare like this if i just write here dollar i'll save this and also here if i write here dollar i'll save this and now if i refresh this one you can see i'll be getting this error okay while creating variables inside constant we should not give this dollar symbol we can give this underscore i'll just remove i'll be giving underscore i'll save this i'll refresh this one now you can see i'll be getting the output as kanam you can't use dollar symbol but you can use letters and underscore this is the simple example of constants now next we are going to see constant arrays here i'm just going to write here define and inside this first i'll be writing the array name let me just write here colors and inside this i'll be passing some values so here i'll just separate using comma and here inside this inside square brackets i'll just pass some values i'll be writing here blue next i'll be writing here green and finally i'll just write here hello okay now this is the constant arrays now if i want to print the data this is same as we are just using index number i'll just write here colors and inside this i want to print the data of second integer okay second index number that is hello i'll refresh this one now you can see i got the output as yellow as soon as i give it through i'll save this and if i refresh this one again i'll be getting the output as a low but here uh let me just make it as capital c and capital o i'll save this i'll refresh this one you can see i got the output as yellow but here if i just if i just remove through from here i'll save this i'll refresh this one you can see i'll be getting this warning okay constants are nothing but once the variable is declared it is fixed we cannot change the value of this variables now i'll just copy the same thing and here i'll be pasting that one i'll save this i'll refresh this one i'm getting this warning let me just make it as colors and here also let me just make it as colors i'll save this i'll refresh this one you can see i'll be getting this output constant colors already defined but i am getting this output yellow yellow but here i am getting this notice as well so once we are declared it is declared okay we cannot change the value if i just add here orange let me just write here orange i'll save this i'll refresh this one now you can see constant color i am getting the same notice we cannot use same variables we cannot use once we are giving this define and this is the syntax for constants and the most important thing is constant variables will be having global scope okay the variables declared outside the function can also be accessed within the function we have already seen about scopes so here i'll just write uh i'll just write one function and inside this let me just write the function name as my color and inside this function if i just want to print this colors i'll just write here echo and here i want to print colors colors of zero i'll save this and from here i'm just going to comment this one i'll refresh this and i have to call this function i'll just copy this one and here i'll be pasting that i'll save this i'll refresh this one now you can see i'll be getting the output as blue here okay whatever i am having inside index number okay i'll just comment this one now if i show you i'll be getting the output as blue here because inside index number zero i'm having the value as blue and that will be given as the output and this is global slope so we can access outside the function local scope will be within the function we cannot access that variables outside the function but if they are having global scope that variables can be accessed within the function and also outside the function okay this is all about php constants now next we are going to see php operators here i'll be creating one file i'll give my file name as operators operator.php now inside this we are going to see some of the php operators first i'll be writing this syntax now here i'll be writing one comment and here i'll just write here operators below this first i will be writing first operator we are going to see about arithmetic operator i'll just write here now inside this arithmetic operator we have addition multiplication subtraction division modulus we are going to see one by one here i'll just create one variable i'll give the value as 10 and for y i'll just give the value as 20. now i'll just do echo and here i'll just do here x plus y okay this plus is called as addition with addition operator and if i just show you the output before that i'll just copy this path and here i'm just going to paste that one i'll just remove this entire thing from here i'll enter you can see i got the output as 30 this is called as addition operator in the same way we have subtraction i'll just copy the same thing and i'll just uncomment this we just have to write here minus i'll save this i'll refresh this one now i'll be getting minus 10 because 10 minus 20 will be minus 10 again i'll just do the same thing i will come into this one here i'll just write here multiplication i'll save this you can see i got the output as 200 10 into 20 will be 200 i'll just copy the same thing and here i'll just write here division 10 divided by 20 i'll just refresh this one i got the output as 0.5 again we have here modulus i'll just come into this one and here i'm going to copy this and here i'll be writing here modulus i'll save this i'll refresh this one now you can see i got the output as 10 okay this is going to give me the remainder and this is going to give me the quotient okay this division operator will be giving me the quotient and this modulus will be giving the remainder okay this is all about arithmetic operators and we have one more operator that is exponential i'll just copy the same thing and here i'll just write here exponential now in place of this let me just write here smaller numbers i'll just write here 2 and here i'll be writing 4 okay let me just write 5 i'm going to give 2 power 5 whatever i have given here that will be here 2 this double hash trick will be that will be given 2 power 5 2 into 2 into 2 into 2 okay we have these many operators in arithmetic operations i'll just comment this entire thing now below this i'll be writing one more comment and for this i'll just give the name as assignment operator i'll just write here assignment i'll be writing operator we have already seen what is assigning here if i just create one variable i'll just write here variable name as uh my data and inside this if i do this equal to and if i initialize some value i'll just write this cac okay subject name okay this is called as initializing um i'm initializing cac to this particular variable okay so first we have this initialization that is equal we are just initializing this value to that variable i'll just comment this one now here i'll just create one variable i'll give my variable name as number and inside this i'll just give the value as 2 now we are having this one i'll just write this number number plus or equal to uh i'll just write 2 and also i'm just going to print that one echo i'll be writing here number i'll save this now first my value of number is 2 so here it will come it is going to give number plus or equal to 2. so number value is 2 so 2 plus 2 whatever i am having here 2 plus 2 i should be getting 4 i'll refresh this one you can see i got the output as 4. now if i just give here 20 uh let me just give you 20. so 2 plus 20 will be 22. i'll refresh this you can see i got the output as 22 okay this is how it is going to work we have another thing we have here minus 2 minus 20 will be 18 i'll refresh this you can see i got the output as 18 and also we have here a hash trick i'll save this multiplication i'll refresh this 2 into 20 will be 40 and also we have this division 2 divided by 20 i should be getting here 0.1 and finally we have here modulus i'll just write here modulus i'll save this 2 modulus of 20 i should be getting here 2 okay this is all about assignment operator we are just assigning that one and we are increasing decreasing we are multiplying based on what we need we can do lot of stuff here ok this is all about assignment operator i'll just comment this one now below this we are going to see comparison operator i'll just write the comment now here first we are i'll just write one number let me just write here x is equal to 10 and i'll be writing y is equal to 10 now first we are going to see equal so here i'll just write here echo x is double equal to y we have to write like this to check whether it is equal to or not if we give one equal to that means we are assigning the value but if we give double equal to that means we are checking the condition i will just refresh this one you can see i got the output as one which means it is true if i just give here one not one i'll save this i'll refresh this one you can see i don't have any output because it is false now instead of this one if i just give here val dump and here i'll be closing this one i'll save this i'll refresh this one you can see i'll be getting the value as boolean false now if i just give here 10 i'll save this i'll refresh this one you can see i got the output as true okay now this is true this is called as equality now suppose uh for y if i just give here if i make it as string okay now this value is same this 10 and this value 10 is same but the data type is different is going to check only the value it is not going to check the type okay to check the type we have here triple equal to now this is going to check the type as well now if i refresh this one you can see i'll be getting the output as false because this is integer and this is string if values are same it does not matter data type should also be same when we give this treble equal to operator okay triple equal to now next we are going to see not equal to i'll just write here not okay this is not symbol i am just writing that one not equal to now this not equal to operator will return me false because this both are equal okay 10 and 10 because it is going to check only the values and these values are equal so it is going to return me false if it is if i just give if it is not equal to then it is going to return me through i'll refresh this you can see i got the output as through now in the same way we have here not triple double equal to now this is going to return this is going to check both the type and the value i'll refresh this one first i'll be getting here through because it is going it is not equal now suppose if i just give here 0 and here if i just give here 0 i'll save this now these are not equal so i'll be getting here true you can see i'll be getting the value as through if both if i give here a string i'll just give his string now this both are equal so here i'll be getting the value as false so this is going to check both the type and the value but this not equal to only one equal to if i give this this is going to check only the value now in if you don't want to write this one you can just write like this this is also not equal to i'll save this and here if i just refresh this one you can see again i'll be getting the value as boolean false because this this both are equal so here i'm just checking the condition if it is not equal to only then give me the output as through or else you give me the output as false we have another we have here greater than if x is greater than let me just write here 10 and remove this i'll be writing here 10 and here i'll be writing here hundred okay you can see here i'm just telling that if my x is greater than y then print me then give me the output i'll refresh this you can see i got the output as false because x is less than y now if i just give here less than symbol i'll save this i'll refresh this one you can see i got the output as true because x is less than y in the same way we have x is less less than or equal to i'll save this i'll refresh this one i'll be getting the output as true because yes it is less than so it is going to check only one condition if it is less than yes it is going to return if i just give here greater than or equal to i'll save this i'll refresh this one i will be getting false because it is not greater than it is not equal to if i just give here 100 i will save this i will refresh this one you can see it is going to return me through okay because x is greater than its not greater than but it is equal to y and we have one more new operator that is php spaceship operator so for that we are just going to write like this okay this is called a spaceship operator and now this both are equal so i will be getting the output as you can see i'll be getting the output as 0 here integer of 0 if i just give your 101 i save this i'll refresh this one now you can see i got the output as 1 because now x is greater than x is greater than y if the left hand side is greater than then i'll be getting the output as 1 if they are equal i will be getting the output as 0 if it is less then i will be getting in negative numbers i'll refresh this i'll refresh this one you can see i got the output as minus 1 if the left hand side is less then i'll be getting minus 1 if it is equal i'll be getting 0 if it is greater than i'll be getting as one this is all about comparison operator we have assignment we have equal to not equal to greater than less than next we are going to see about increment and decrement operator now below this first we are going to see i'll just create one variable i'll just write my variable name as number and i'll assign the value as 10. now for increment i'm just going to increment by one so i'll just write here number plus plus so this is as equal to like this okay we have already seen that one i'll just write here number plus or equal to this particular number whatever i have given here not this one i'll just write here one okay this is going to increment by one this is also same and this is also same you can write any one of this now here i'll just print echo number i'll just copy the same thing from here i'll just paste that one here i'll save this now first my value of number is 10 then i'm incrementing by one so here i should be getting 11. now you can see first 10 and second 11 okay this is called as post increment now in the same way we are having this decrement now first my value of number is 10 it is going to decrement by 1 then i will be getting the output as 9. you can see first 10 and then i'll be getting 9 we have here pre increment as well i'll just write here number i'll be writing here minus minus sorry plus plus pre increment i'll save this i'll refresh this one you can see again i am getting the output we have some basic difference between this and this that is called as post increment and this is called as pre increment we have totally pre-increment post increment pre-decrement and post decrement now i'll save this one i'll refresh this now you can see i got the output as nine post increment is first the value will be printed and then it is going to increment pre increment is first it will increment and then it is going to give the output now here i'll just write one comment i'll be writing here logical operator i'll just write the comment we have and we have or we have xor okay i will be explaining you one by one and also we have not okay we are going to see this one i'll just create one example for this now we are going to see these examples and first we are going to see about and operator and operator is it is going to return the output when both the condition is true now i'll just create one variable i'll just give the variable as 10 and i'll just create one more variable y i'll just give the value as uh let me just give it 15. now here i'll just check the condition if my x is if it is equal to equal to 10 and and if my y is equal to equal to 15 i just want to print this one i'll just write here echo ah i am printed i'll just write this one if both the condition is true only then it is going to print i'll come here i'll refresh this one now you can see here i'll be getting the output i am printed here now suppose if i just give here one not one now this condition is false okay x is not equal to ten it is equal to one not one so here if i just refresh this one you can see i will not be getting any output it is not going to come inside this one it will come outside let me just echo somewhere i will just write here i am not i am outside i'll save this i'll refresh this one now you can see i'm getting the output as i am outside it will come here it will check the condition this is false and this is true so it is going to fail this one it will be printed this one okay now we are having our operator for and you can also use this one and symbol i'll save this i'll refresh this one again i'll be getting the same output i am outside if i just give here 10 i'll save this i'll refresh this one now i'll be getting both the output i am printed and next i'm getting this i am outside okay this output will also be printed because this both the conditions are true now next we are going to see about or operator i'll just write the comment or operator i'll just copy the same example and below this i'm just going to paste that one now here i'll be writing here or now this or operator if any one condition is true then it is going to come inside this loop and it will be printed i'll just uncome i'll just comment this one i'll refresh this now you can see i'll be getting the output as i am printed because both the conditions are true and i will be getting the output suppose if i just give here 150 now only the first condition is true because x is equal to 10 but x y is not equal to 150 this condition is false if any one condition is true then i'll be getting the output as i am printed you can see if i refresh i'll be getting the output as i am printed using and both the condition should be true for or any one condition should be true now we have not now we are going to see example of not operator i'll just write here not for not we have this symbol not symbol and here let me just write the example for this i will just comment this entire thing now notice it is going to reverse the condition okay if i am having 1 it is going to change to zero now suppose if i just write here x is equal to zero and here if i just want to print i'll just print here not of x i'll save this i will refresh this one now you can see i'll be getting the output as one okay this is just going to reverse the condition and it will be given the output this is how not operator works if we have zero it will change to one if we have one it will change to zero okay now next we are going to see about xor operator i'll just copy the same thing entire or and here i am going to paste that one and here i'll just write here xor operator now for xor operator any one condition should be true both the condition should not be false and both the condition should not be true okay if any one if either one off is true then it is going to print here if i just write here x or now x is equal to 10 yes if y is not equal to 150 i'll just comment this one so now this condition is true so it will come inside this one and it will be printed i am printed i will refresh this you can see i am printed now here if i just give here y is equal to 15 and x is equal to 10 now this both the conditions are true now when both the conditions are true it is not going to come inside this it will directly come outside this condition and it is going to print whatever i am having you can see i am having here i am outside okay this will not be printed because both the conditions are true but using and both the condition should be true but using or both the conditions can also be through any one can be true and not operator is going to reverse whatever condition i am having it is just going to reverse that one okay this is how this works now both the conditions are true so it will not print this one and it is going to print this one now suppose if i just give here both the condition as false i'll just write here 100 i will be writing here 150 now both the conditions are false if i refresh this again i'll be getting here i am outside because both the condition should not be false both the condition should not be true either one of them should be true only then it will be printed okay this is the difference between xor and or i'll just comment this one now next we are going to see some of the array operators i'll just write here array operators and first i'm just going to define one array i'll just write here colors and inside this we are going to write this array syntax and inside this i'm just going to write some colors i'll be writing here blue and here i'll just write here green now we are going to use associative arrays for blue let me just give here i have only two pens and for green let me just give here i have totally five pens for green okay this is my first array i'll just write here color one okay let me write here colors one in the same way i'll just copy the same thing and here i'll be writing colors now instead of blue let me just write here black and green i will be writing here yellow now we are going to see array operators first we are going to see about union operator union operator we are going to use plus symbol this is called as union operator in arrays now this is going to combine both the arrays and it is going to print the output now if i just do here print r and first is my colors one i'll just write here colors one plus colors 2 colors 2. i'll save this i'll refresh this one now you can see first i'm having blue green black and yellow ok this is going to return the output in one array this entire thing will be combined and this is going to give the union okay union is nothing but combining everything and giving the output now this plus operator is used for union in arrays i'll just write here this is union operator in arrays next we have equality operator that is nothing but double equal to and this equality operator if it is having the same value same keys and same values then it is going to print the output as true or else it will be printing the output as false now here i'll just copy this i'll just copy the same thing and here i'll be writing that one and here instead of this i'll just write here equal to equal to and let me just write here val dump okay so that we will get the output in boolean form i'll just write here varnum and here i'll be closing that one i'll save this and i'll be commenting this union now if i refresh this one you can see i'll be getting as boolean false because both the keys and both the values are different i'll just comment this one and i i'll just copy the same thing and here i'll be writing colors too i'll save this now both keys and both values are same now if i refresh this one you will be getting the output as boolean through because both this are same okay both keys and both values are same in both the array so i'll be getting the output as through if it is different then i'll be getting the output as false now even if i just remove this one green from here and here if i paste that one i'll paste that one i'll save this i'll refresh this you can see again i'll be getting the output as through uh again let me just paste that one here i'll save this i'll refresh this one you can see i'll be getting the output as through here because it is only going to check whether i am having this blue green in another array i am having and it is going to print the output but using this triple equal to the values and keys should be in same order only then it is going to print the output as through i'll refresh this you can see i got the output as false boolean false again if i just copy the same thing i will just remove this from here and here let me just make it as colors 2 i'll save this i'll refresh this one now you can see i'll be getting the output as boolean through because both the keys and both values are in same order i'll just copy this blue from here i'll just paste that one after green i'll save this now if i refresh this one you can see i'll be getting the output as false because this keys and values in both the array should be in same order and also at the same place only then i will be getting the output as true or else i'll be getting the output as false okay this is called as identity operator and double equal to is equal equality operator this one is equality and that is nothing but and this is nothing but identity i'll just write here identity and from here i'll just copy this one and here i'll be pasting that identity and from here i'll just remove one equal to this is called as equality and this is called as identity operator in arrays next we have not equality i'll just write here not equality now this is going to return if it is not equal i'll just cop okay i'll just copy the same thing and here i'm going to paste that one and let me just write it not equal i'll save this it is going to return me the output as false because this both are equal now if i just give here 50 i'll refresh this one now you can see i'll be getting the output as true because this both are not equal here i am just checking the condition if my colors 1 is not equal to colors 2 then print me the output and that is nothing but it is giving me true okay if these are not equal it will give through if it is equal then it is going to give false okay this is called as in equality operator i'll just write that one here i'll be writing here in equality next we are going to see about conditional assignment i'll just write one statement i'll be writing here conditional assignment we are going to see about ternary operator here and this is called as ternary operator question mark and colon first i'll be writing the syntax of this now here i'll just write here expression okay this is the syntax for that this is my expression and here i will be writing this question mark if it is true then first condition will be printed and if it is false then second condition will be printed we are going to write this question mark and colon like this if my expression gets true then this whatever i am having here that will be printed or else this will be printed now we are going to see example of this now here i'll just write x is equal to 0 and here i'll be writing here if x i'll write a con condition i'll be writing here true and i'll just separate using comma and here i will be writing false i'll save this and also i'm just going to do here echo i'll save this i'll refresh this one you can see i'll be getting the output as false because my x is 0 so this condition is going to fill and it will come to the false part okay now we are going to see another example here i'll just create one variable x x is equal to let me just write here hello now here i'll just echo this one and echo i'll be writing here if my x dollar x if it is equal to equal to high okay which is false so here i want to print here i am true and next when my condition is false i want to print this one i am false i'll save this okay you can see my x i have assigned the value as hello so here i am just telling that if my x is equal to high which is false so it will come to false part and this i am false will be printed i will refresh this one you can see i am false will be printed if i just give the same value i will just copy this and here if i paste that one i will refresh this now you can see i will be getting the output as i am through okay if the condition is through whatever condition we give here if it is true this part will be printed if the condition is false then this part will be printed after colon this is all about conditional assignment and ternary operator this is called as ternary operator if the condition is true first statement will be printed if the condition is false second statement will be printed and this is all about php operators we have seen about arithmetic operators we have seen about assignment operators comparison operators increment decrement logical operators are nothing but and or x or not finally we have seen array operators and conditional assignment that is nothing but ternary operator okay i am just going to comment this entire thing now here i will be creating one new file now we are going to see about conditional statements i'll just write here 7 i'll be writing my file name as conditional i'll just write conditional.php now inside this file first i'll be writing the syntax of php now inside this i'm just going to write one comment i'll be writing conditional statements now conditional statements are nothing but they are used to perform different actions based on different conditions whatever conditions we give if the condition is through it is going to print or else it is not going to print and we are going to see many conditional statements here first we are going to see about if conditional statement we have already seen many times about if but we are going to understand what is this one okay now here i'll just create one variable let me just write here a a is equal to 9 i'm just assigning one value to a now here i'll just check the condition if my dollar a if my value of a if it is equal to equal to 9 then print this one whatever i am having here yes i am 9 i'll save this i'll just copy this file path and here i'm going to paste that one and i'll just remove this i'll be writing here local host i'll enter and here you can see here i'll be getting the output as yes i am nine if i just give here 90 i'll save this i'll refresh this one now you can see i will not be having any output i'll just close this because this condition is false now if this condition becomes false it will never come inside this one and it will not execute whatever i am having here but it will come outside this i'll just write here echo i am nine okay let me just write here i am outside i'll save this i'll refresh this one now i'll be getting the output as i am outside okay once this condition fails it will never come inside this one and it will come outside and whatever i am having here that will start executing okay this is about if statement if the condition is true only then it will execute or else it will not execute i'll just comment this one now we are going to see about if else i'll just write here if else if else conditional statement and this condition is okay let me just write one example here i'll just write here uh i'll just write here day and here i'll be writing here sunday i'll be writing here sunday and here i'll just check the condition if day if day if it is equal to equal to sunday if it is equal to sunday then echo uh it's holiday i'll just write here it's holiday now if this condition is true this will be executed else if this condition is not true then i'll just write here i'll paste that one it's not holiday i save this now my day is equal to sunday here the condition is through so it will come inside this one and its holiday will be printed it will never come inside this else part because because here it is through and only this will be printed i'll refresh this now you can see i am having the output as its holiday now once i am done with this i can do anything here i can print anything here and that will be printed in both the cases even if the condition is true this will be printed even if the condition is false this will be printed i am optional i am optional and always printed i'll just write this one i save this i'll refresh this one now you can see here i'll be getting the output it's holiday i am optional and i am always printed let me just add here breaks i'll save this i'll refresh this one now you can see i'm having both the output now suppose if i just give here let me just write here monday now this condition is false so it will not come inside this one it will go inside else part and this will be printed and once this condition once this is done it will come outside this one and this will be printed i'll refresh this one now you can see here i'll be getting it's not holiday and i am optional and i am always printed in both the condition even if the condition is true this will be printed even if the condition is false this will be printed and basically if else is if the condition is true if part will be executed if the condition is false else part will be executed okay that's all about if else we have seen about if we have seen about if else now here i'll just come in this entire thing now we are going to see if fell slider i'll just write here if else and again i will be writing here if fell slider okay now this is going to check multiple condition and whichever condition is true that will be executed now here i'll just copy okay let me just write here new example i'll just write here uh time time is equal to let me just write here eight okay that is nothing but eight o'clock assume that one now here i'll just check the condition if my time if it is less than 12 then just echo this one good morning and just write here good morning now next i'll be checking the condition else if if time is i'll just write this dollar time variable if if it is less than 17 that is five o'clock i'll just i just want to say good evening i'll just copy this one i'll be pasting that one here okay let me just write here twenty eight o'clock i'll just write here twenty uh i'll just write here good evening not good evening okay let me just write here 17 and here i'll be writing good afternoon and finally if both the condition are false then this will be printed that is nothing but i'll just copy this one here i'll be writing that i'll just write here good evening i'll save this now my time is equal to 8 first it will come here if my time is less than 12 yes it is so good morning will be printed i'll come here i'll refresh this one now you can see good morning is printed now suppose here if i just give here 18 that is 6 o'clock now my time it will come here 18 is less than 12 no it is false so it will come to this condition 18 is less than 17 no it is false so again it will come to this and this will be printed that is nothing but good evening you can see good evening is printed now if i just give here 15 i'll save this now it will come here 15 is less than 12 no it will not come inside this and it will come to this else part 15 is less than 17 yes it is so good afternoon will be printed i'll refresh this one now you can see good afternoon is printed okay this is called as if fell slater you can add as many as conditions you want i will just write here else if and here i am just going to write the condition let me just write here if my time if my time if it is less than let me just write here 20 okay let me write here 22 that is 10 o'clock then i want to print here good evening else i'll just write here good night i'll just copy this one and here i'll be pasting i'll just write here good night i'll save this now my time is 15 so this condition is true good afternoon condition that will be printed i'll refresh this and here i am having good afternoon if i just give here 23 i'll save this now this condition is false 23 is not less than 12 it is false so it will come this will check this will be checked and 23 is not less than 17 so again it will come here 23 is not less than 22 then finally else part will be printed i'll refresh this now you can see goodnight is printed okay this is how if else ladders work you can give multiple conditional statements in this instead of using this efl slider we have another conditional statement that is nothing but switch i'll just comment this one in place of if else ladder you can use this switch conditional statement now this switch can okay i'll just write a proper spinning switch now using this switch statement we can select multiple blocks and we can print the output it is going to check the condition for each block and that block whatever if the condition is true that block will be selected and that output will be printed okay let's see an example for this okay let me just write here color color is equal to i'll be writing here hello now here i'll be writing this switch statement and inside this i'll just pass the condition that is nothing okay let me just write here color i'll copy this and here i'll be pasting that one now my switch is having the color as yellow and here i'll just write the condition here we have to write this case and here i'll be writing this value i'll just copy this one and okay not the yellow let me just write here red we just have to write here colon and here i just want to print something i'll be writing here i'll just write here this is red this is red now again i'll just write one i'll be writing one more case here case i'll be writing here purple okay you can when it is day you can give the day number you can give numbers okay based on your requirement you can give anything here i'll be writing here this is purple this is purple and finally i'll just write my final case that is nothing but yellow whatever color i have given i'll be writing that one yellow and inside this i will be printing this one this is hello i'll copy this here i'll be pasting that one and here i'll just write here hello i'll save this now if i show you the output i'll refresh this one now you can see here this is yellow is been printed because this color is low so it will come here it is false again it will check here this condition is not matching again it will come here this condition is matching and here i am getting the output but the problem is if i just copy the same thing and here if i paste that one and instead of this purple instead of purple let me just write here green i'll copy this and here i'll be pasting that one i will save this i will refresh this one now you can see this is yellow and this is green okay both is printed but only one condition is true then why this condition is getting printed because in switch statement we should always add break here i'll be writing here break now this is going to prevent the execution of the next statement i'll copy this here i'll be pasting that one and here i'll be pasting that one i'll save this i'll refresh this one now you can see only this is hello will be printed and this is going to break this one and it is going to come outside of the loop and it is not going to check for this condition once my condition matches here okay this is about else now suppose here let me just write here white now i don't have this white at all so all the condition gets filled i'll refresh this one now here i will not be having any output so to get some output we are having another we are having one case that is default and here i will be writing here echo i am not uh i am not in list okay let me just write that one i am not in list i'll save this i will refresh this one now you can see i am not in list will be printed okay this is how switched condition will work whatever color you have given here i am just passing inside the switch and here i am just checking the condition if my case is red whatever color value i am having here if it is red then show me this one if it is purple then show me this one if it is yellow then show me this one here i have passed white white is not there so it is not going to execute any of the case statements so directly it will come to default statement and this will be printed if it matches then particular statement will be printed and we have to give here break back so that our case will stop executing and it will come outside of the loop we will be getting that particular output now suppose here let me just write here some numbers i'll just write here one i'll just write 10 now in instead of writing in single quotes you just have to write like this 10 and here i'll be writing here 11 and here i'll just write here 12 and here i'll be writing 13 i'll save this now 10 this is matching this is red will be printed i'll refresh this one you can see this is red that will be printed okay this is how switch will work in place of if else ladder you can use this switch conditional statement okay we have seen about if if else if i'll slather and switch now next we are going to see about loops here i'll be writing i'll just create one file i'll be writing here loop dot php it's loops i'll just write here loops dot php file now inside this file first i'll be writing the syntax of php and here i'll just write one comment i'll be writing here php loops now below this i'll be writing one comment i'll be writing here for loop okay for loop we have already seen but we are going to understand here for loop will be having three arguments first will be the initialization second will be the condition and third will be the increment or decrement okay here i will be creating for loop and inside this let me just create one variable x and here i'll initialize the value as 0 the starting value of x will be 0 we have to separate using semicolon and here we have to give the condition i'll just give here if my x is less than 10 okay here i just want to increase the value of x for each loop now here i just want to print the value of x i'll just write here x now first my value of x will be 0 so it will come here it will print the value x and i'll let me just give here echo and i'll be writing here break so that my each values will come in separate lines first my value of x will be 0 so it will come inside this loop and x will be printed then it will increase the value of x no ma value of x will be 1 so here now value of x is 1 it will check the condition 1 is less than 10 yes it is so it will come inside this loop and it will print the output as 1 again it will increase the value of x now my x value is 2 it will check the condition 2 is less than 10 yes it is so it will come inside this loop and 2 will be printed when my value of x reaches to 10 so my value of x is 10 now it will check the condition 10 is less than 10 it is false so it will come outside of the loop and from 0 to 9 will be printed okay i'll just copy the path and here in here only i'll just paste that one and from here i'm just going to remove this i'll just write here localhost i'll enter you can see 0 1 2 3 for totally 9 values it's been printed from 0 to 9 it will be printed if i just give it 20 from 0 to 19 the values will be printed you can see from 0 to 19 all the values will be printed ok this is how we are going to loop through numbers and we are going to print the data ok this is our first for loop and second we are having for each loop this also we have already seen when we were studying about arrays but we are going to see this example now now this for each will loop through arrays for each element inside the array it is going to loop through and it will give the output here i'll just create one variable fruits here i'll be passing array inside this first i'll be writing apple orange banana now here i'll be writing this for each inside this first we have to write this array name i'll just paste that one as we have to give here values now first time this will be having apple second time orange and third time banana now here i want to print the values here i'll just write here echo and here i'll be printing values i'll save this i'll refresh this one you can see apple orange and banana let me just give here break i'll save i'll refresh you can see apple orange and banana first one this is going to take apple second orange and third banana okay inside this look first apple will be printed again it will come it will come here it will print orange and then finally banana will be printed this is an example we have already seen this one this is indexed arrays basically this is the simple array now we are going to see about associative arrays and we are going to loop through that one using for each now here i will just create one variable let me just write here my name let me write here my data and inside this i'll be writing here arrays and here i'll be passing key value pass so first i'll be writing here name and inside this let me just write here khanam so again i'll be writing here branch and here i'll just write here cse okay two values i have passed inside this one and here i am having this here i'll just close i'll just close that one now below this i have to loop through each array so for that we are going to use this for each for arrays we are having this forage inside this first we have to give the array name i'll paste that one here as we have to give the key value paste so for key i'm just going to give the variable as x you can give any variable names and for values i'll just give your values now this x will be storing this name whatever i am having here on my left side and this values will be storing whatever i am having on my right side now here i want to print the data here i'll just write here echo first i want to print the value of x and also i just want to print the value of i just want to print the values i'll save this i'll save this i'll refresh this one now you can see first name is equal to khanam and branch is equal to cac ok this is how it is going to loop let me just add here let me add here break i'll just copy this break from here and here i'm going to paste that one i'll save this i'll refresh this one here you can see name is equal to khanam and branch is equal to cse it is going to loop through this array and each time it will store one value and that will be printed now here let me just add here a place i'll just close in double quotes i'll be writing here place and here i'll just write some random place i'll be writing here mysore i'll save this i'll refresh this one now you can see i'm having the place as mysore okay this is the example for associative arrays and this is called as for each loop for loop we are just seeing the simple example and for each look we have seen this both the examples using arrays and using associative arrays now we are going to see another type of loop that is nothing but while loop here i'll just write one comment here and here i'll be writing here white loop okay first we are going to see the example and then we will see what is while loop here i'll just create one variable i'll just give my variable as x for this i will initialize the value as 1 now here i'll be writing this while loop and inside this i'm just checking the condition if my x is less than 6 okay so 1 2 3 4 and 5 will be printed here i want to print that x so here i'll just write here echo and i want to print the value of x and also i want break i'll copy this one and here i'm going to paste that one okay now here if first my value of x is 1 so it will check here 1 is less than 6 yes it is so it will come inside this loop and 1 will be printed now i have to increase the value of x so inside this i'm just going to increase the value of x i'll just write here x plus plus now once one is printed it will break and it will increase the value of x now my value of x is 2 it will come here 2 is less than 6 yes it is it will come here 2 will be printed again the value of x will be increased it will be 3 it keeps on going and once it becomes 6 now 6 is less than six it is false so it will come outside of the loop and it will not be printed anything from zero to from one to five it will be printed i'll refresh this you can see from one to five it is printed now if i give here zero from zero to five it will be printed i'll refresh this one see from 0 to 5 it is printed ok this is called as while loop it is going to loop through numbers and once the specific condition gets filled it is it is going to come outside the loop and it will stop the execution now we have another type of loop that is nothing but do while loop i'll just write here do while now this is same as while loop but the basic difference is at the end we are going to check the condition now here i'm just going to copy the same example here i'll be pasting that one i'll just remove this now here instead of this while i'll just remove this while from here here i'll be writing do and here i'll just check the condition last i'll be checking the condition we are going to see the difference between them i'll refresh this one you can see i got the same output from 0 to 5. the basic difference is even if the condition gets fail okay here i am having x is less than 6 i'll just write here 10 i'll save this now this condition is false here okay 10 is not less than 6 so this condition is false but even if the condition is false at least one time this output will be printed and here i'll whatever value i am having that will be getting me as an output now only 10 will be printed you can see only 10 has been printed but in while loop first the condition will be checked if the condition is filled it is not going to print anything now if i just uncomment this and here i'm just going to comment this one now here i'll just write the condition i'll just give the value as 10 i'll save this i'll refresh this one you can see here nothing will be printed because this condition is getting failed here it will never come inside this loop and nothing will be printed but using do while loop at least one time i will be getting the output and at the end i am checking the condition so if the condition gets fail at the end then it is going to stop but at least for once it is going to print the output here okay this is the difference between while and do while i will just comment this entire thing and also i'm just going to comment this entire thing now we are going to see about break and continue i'll just write the comment as break now this break we have already seen in switch now this exam break it it is going to stop the execution now here i'll just write i'll just write here for loop and inside this i'll just create one variable x is equal to 0 i'll check the condition if x is less than 10 and here i'm just writing here x is x plus plus now inside this i just want to print here echo and here i will be writing this one echo i just want to print here x i'll just break from here i'll just copy this break and here i'll be pasting that one and here i'll just check the condition if my value of x if it is equal to equal to 2 let me just write here 6 if it is equal to equal to 6 then break i'm just giving the condition if it is equal to 6 then break let's see the output i'll refresh this one you can see i'm getting the output as 0 1 2 3 4 5 and 6 because till 6 it will be printed here and it will come here ok for each time it is going to check for 0 it is going to check 0 is equal to equal to 6 false so it will not come inside this again this condition will be executed then my value of x will be incremented here i will be getting x 1 so 1 will be printed here i will be getting break and here it will check the condition 1 is equal to equal to 6 no it is false so again it will increase the value of x and it keeps on checking once my value of x is 6 so it will come here 6 is less than 10 yes it is so value of 6 will be printed it will give break back now here it is checking the condition if 6 is equal to equal to 6 yes it is then we are breaking and rest it is not going to execute 7 8 9 and it is not going to print that output only from 0 to 6 will be printed you can see here only from 0 to 6 this break is going to stop the execution now let me just copy this one and before first only i'll be checking the out condition i'll just write here continue i'll refresh this one now you can see the basic difference between break and continue 1 0 1 2 3 4 5 6 is not printed seven eight nine is printed if my condition if my x is equal to equal to six continue this one and skip that iteration okay if it is six only skip six and rest all we are going to continue if i just give here seven skip seven and rest all we are going to continue you can see i'll be getting 6 but 7 will not be printed the entire rest 8 and 9 will be printed ok this is not going to stop the execution this is going to continue the execution and it will give the output break is going to completely stop the execution once the condition satisfies but using continue it is going to continue the output okay this is the difference between break and continue okay we have seen about loops in php we have for loop for each loop is used for arrays while loop do while loop and break and continue we have seen okay these are two statements break and continue statements i'll just comment this entire thing now here i'll be creating one file i'll just give my file name as functions functions functions.php now inside this file first i'll be writing syntax of php here i'll just write one comment i'll be writing here functions now function is nothing but it is a block of statement that can be executed again and again when it is called okay functions are very useful and it allows us to keep our code dry that is don't repeat yourself okay we can call the same function again and again and we can call anywhere inside the program now here first we are going to see the syntax here we have to write this function keyword and we have to write here function name okay and this will take function name and inside this curly braces we have to write the code whatever we want and to call this function whatever function name we have given we just have to call the function here okay now whatever code we are having inside this function that will be executed when it is called if i call here two times then whatever code i am having inside this function that will be called twice and it is going to print the output okay this is the syntax of creating functions now here we are going to see the example here i'll just write here function and i'll be giving the function name as message now here i'll be writing here echo and here i'll be writing here thank you okay this is my message that is thank you and here i'll okay i'll just save this one i'll just copy the path i'll paste the path here and from here i'm just going to remove this i will just write here localhost now you can see nothing will be printed but here i am having this echo statement but it is not printed because we have seen to execute this function we have to call the function like this whatever function name i am having here you can give any function name here i have to call this one i'll save this once it is called it will come inside this function and whatever i am having inside this function that will be printed i'll refresh this one now you can see i got the output as thank you now if i want to print multiple times i'll ah call this multiple times and here i'll be adding this break so that i'll be getting output in separate lines i'll refresh this one you can see i got the output as thank you thank you how many times i called that many times my function will be executed and this i'll be getting as my output okay this is the norm this is the basic example of function now next we are going to see function with arguments now here ah let me just write here one message okay let me just write one argument here i'll just write here name now here inside this i'll be writing here thank you uh i'll just write here name i'll save this i'll refresh this one now you can see i'll be getting this error uncaught argument count too few arguments to function message now here i have passed this argument here i am executing this one but here while calling this one whatever i am having here that should be passed here now inside this one let me just write here audience i'll save this i'll just comment as of now i'll refresh this one you can see thank you audience will be printed now in the same way i can give multiple values here thank you uh let me just write here thank you people and here i'll be writing here thank you uh thank you everyone i'll write here thank you all and finally i'll be writing here thank okay i'll just remove this one i'll save this i'll refresh this one you can see first i'll be getting thank you audience thank you people thank you everyone and thank you all let me just write here break i'll just write here break i'll save this i'll refresh this one you can see each time i'll be having this output first time audience people everyone and all this is going to take this arguments and this is going to print the data we can give multiple arguments as well name and here i'll be writing here greetings here i'll just write here greetings i just want to print here greetings now here inside this i'll be passing here good evening now you can see i'm having the output good evening thank you audience okay i'll just give in capital letters i'll save this i'll refresh this you can say good evening thank you audience okay in the same way i can do the same thing i'll just uncomment this entire thing and here i'll just separate using comma and here instead of good evening let me just write here good afternoon i'll copy this and here i'll be pasting that one and here also i'll be pasting that one and finally here also i'll be pasting that one here i'll change good afternoon good morning and here good night i'll save this i'll refresh this you can see good evening thank you audience good afternoon thank you people good morning thank you everyone good night thank you all okay this is how we can add multiple arguments and we can print the data okay you can call as many times you want and for each calling we this function will be executed and we are going to get the output whatever we are having inside this now we have already seen that php is loosely typed language which means that we are not going to declare that when we are creating variables we don't have to tell it is integer or it is string or it is boolean okay by using the values it is going to detect that one and it is going to assign okay based on the values it is going to assign so here if i just write here one example i will be writing one example function i'll be writing here numbers my function name is numbers now now inside this let me just write here okay let me just write here integer as x and here i will be creating one more argument that is nothing but integer i will be writing here b now both i have passed as integer now here i am just returning that one okay this return we are going to see what is this i just want to return a plus no sorry x plus y here i'm just going to give here y x plus y i'm just going to return that one as my output now i'm just going to print this i'll just do echo and while echo i'm just going to call this function i'll just copy this function and here i'm going to paste that one inside this i'll be passing this arguments okay whatever i am passing here integer i'll just write here 10 comma 100. now this function is called here it will come inside this function it is going to return 10 plus 100 that is nothing but 1 not 10. so you can see one not ten as i got as my output now here in place of this hundred if i in place so if i just give a string i'll save this i'll refresh this one again you can see i'll be getting the output as one not n but this is string we already know if we close in single chords or double quotes that will be acting as a string but here string is also getting added because php is loosely typed and based on the value it is going to detect and this is nothing but string but here we are having number now this is going to convert into integer and we will be getting the output as 1 not 10. if i give here 200 i'll save this i'll refresh this one i'll be getting the output as 210 but we don't want this one we will never add strings and numbers if we add at least we should get some this is not a number like this we should be getting some error so to avoid this so to avoid this confusion we should be adding a strict mode and to declare that when we just have to write here declare okay and this should be on top line here we just have to write his strict types here if we have this suggestion okay i'm not having suggestion i'll be writing that one strict types six types it is equal to one we just have to write this one now this is not going to allow like this it will not add numbers and strings as soon as we give this one now if i refresh this you can see i'll be getting this error and caught type argument passed on numbers must be type of int okay and we have given the string so it is going to generate error if we give this one okay we should give this one only then it is not going to convert or it is not going to convert any strings into integer and and it is not going to add any numbers okay it should generate errors while we are adding numbers and strings this is about strict mode in php i'll just comment this one now what is this return keyword we are going to see that one now this return keyword is going to return if we write echo and that output will be printed on the screen now inside this function we are just going to return this as an output button in php 7 we have new way of returning this one using this colon symbol okay we will see one example using this i'll just copy this entire same thing and here i'll be pasting that one i'll just uncomment this now here we have defined the strict mode and inside this function i'm just writing here number my function name is number and inside this i'm having here two arguments first is x and second is y now here i'm just telling that it should return integer value here i'll just write colon after writing colon i'll just write here float it should okay let me write here integer because it is going to return integer as the output i'll just write here in now this is going to return integer and inside return i'm just passing those values while calling this function if i just write here 10.4 and here if i just write here 10.4 i'll save this i'll refresh this one you can see i'll be getting error type argument must be type in float given i have given float numbers here so i'll gen so i'll be getting error now if i give here 10 comma 10 i'll save this i'll refresh this one now you can see i'll be getting the output as 20. okay in php 7 this was introduced this return declaration okay we just have to write here colon and whatever whatever we want to return which data type we want to written we we are writing that one and we are getting this output now in place of ink if i just write here float now if i add float and integer i will be getting the output as float so here i'll be passing here float and here by calling the function let me just write here 10.8 i'll save this i will refresh this one now you can see i'll be getting the output as 20.8 okay this is how it is going to work whatever output we are getting that we are writing here that data type we are writing here and inside written we are just adding these two arguments and we are calling this one and we will be getting the output here okay this is all about functions in php now here i'll just create one file i'll give my file name as 10 underscore i'll be writing here variables i'll just write here global variables globalvariables.php i'll just close all the files now inside this file first i'll be writing this php syntax and here i'll just copy this file path and here i'm just going to paste that file path i'll just remove till here i'll be writing here localhost now here i don't have any output inside this now here i'll be writing comment i'll be writing here global variables now these global variables are also called as super globals super global variables are nothing but variables can be declared variables can be accessed anywhere inside the code either it is inside the function or either it is outside the function it can access anywhere okay it is not going to see any scope even the variables declared within the function can be accessed outside the function it is not going to have any local scope the variables can be accessed anywhere without caring for the scopes now here we are going to see about first super global variable that is nothing but globals i'll just write here globals now using this the variables can be accessed outside the function and this is going to store the value inside array that is nothing but globals and inside index we are going to pass the variable name okay we will see an example on this and then only we will be understanding what is this globals and why we have to use this one now here if i just write here some value if i write here a is equal to 10 and i will be giving here b is equal to 20 now here i am just declaring two variables outside the function i am not declaring this variable inside the function so here i'll just write here function and here inside this function i'm just going to write here numbers now here inside this function if i just if i just print here echo if i just try to print here a i'll save this and here i have to call this function i'll copy this one here i'll be pasting that one i'll save this i'll refresh this one you can see i will be getting this error undefined variable a in line 10 okay you can see on line 10 i'm getting this error a is not defined inside this function so if i try to print this a inside the function and if i call here then i'll be getting this error okay if i just print here outside the function i'll save this i'll refresh this one now you can see i'll be getting the output as 10 but here i am getting this warning because this a is not declared inside the function but using this globals we can access this variables inside this function now here i'll be writing this globals i'll just write here globals inside this we are going to pass variable name so this is array so inside this let me just write here a result now here again i'm just going to write the same thing global i'll just copy this here i'll be pasting that one i'll just write here a plus again i'll be pasting that one here i'll be writing b i'll save this and now this echo whatever i'm having here that i'll be printing it here okay for globals we just have to write like this okay these are variables these are variables so it should always start with underscore in php i'll just save this one now now this error has gone i'll just come into this now if i just print this one i'll just copy this one and here i'm going to paste that one i'll just close this one i will save this i will refresh this now you can see i got the output as 30. now using this global super variable we can access variables declared outside the function we can access those variables inside this function okay and these are called as variables and they are stored inside array inside index number we are passing this variable names okay these are variable names this is variable name and this is variable name okay using this global we can just access the outside variables now here also i can just print that one and instead now this is my variable this entire thing is my variable now to print this variable i can directly copy this and here i can paste that one i'll save this i will refresh this one you can see again i am getting the output as 30 while printing here i am just giving this global and while printing outside this one now this variable is declared inside the function now i can access outside the function as well because i have path inside this global super variable so it will not think about any scope it is going to execute the output okay this is our first super global variable i'll just comment this entire thing now below this we are going to see our next super global variable that is nothing but a server here i'll just write one comment here i'll be writing server now this server will hold the information about our paths about our headers about her script locations now here let me just print that one here i'll be writing this server now inside this i'll let me just write here php self okay you don't have to worry what is this php safe this php self is going to return the current path of our executing file okay we are inside this global variable dot php now this is going to return the current executing path okay this server will be giving that data of header paths and scripts so using this php self php self is nothing but we are executing this function in the same file now if i refresh this one you can see i am inside php tutorial and my file name is 10 global variable dot php ok it is just going to return the current path we have another method here i'm just going to write here server server and we have this we have this add r now this is going to return the ip address of a local host that is server i'll refresh this now you can see it is going to return something either we can just write here server name i'll save this i'll refresh this one you can see our server name is nothing but localhost okay we have seen php self php self will return the current path server name will return the server name and server address will return the ip address now we have another method that is nothing but request method that we are going to see when we see about get and post now we are going to see about our next super global variable and we have seen about server we have request we have post and we have get okay for that i'm just going to create one more file and we are going to start creating forms okay in that we are going to use post and get method here i'll just create one separate file i'll just write here forms forms dot php now in this file we are going to create forms and we will understand what is get method and what is post method okay here i will be writing this basic boilerplate of html here i'll just change the title to forms i'll save this and i'll just copy the path here i'm going to paste the path now from here i'll just remove this entire thing i'll just write here localhost okay now you can see my title has been changed to forms inside body i'll just create one form and inside this action i want to perform all the action in the same file so i'll just write this php syntax here and inside this using php self that we have already seen php self will return the same current path so for that we are going to use that one here i will be writing server and here inside this i just want to write that php self i'll be writing here php self now this is going to return the current path in which i am working and i want to return the output in the same file now here i'll be writing method we just have to write like this and my method is equal to post now inside this form first i'll be creating one simple input field type let it be text name attribute we have to give name attribute is very important when it comes to php forms here let me just write here f name i'll i'll create another one and here i'll be writing l name that is last name now below this i'll be creating one button and for this button i'll just give the type type i'll be giving a submit now inside this i'll just write the text as submit i'll save this i'll refresh this one now you can see i'm having two input fields and one button here i'll just give break tags i'll save this now all my input fields are on top of each other i'll just give one more break so that i'll get some spacing okay we don't have to give here break tags we can do this by giving styles but as of now we are not going to waste our time in css we are just creating simple form and here button now if you want you can just give the placeholder i'll be giving here placeholder is equal to first name i'll just copy the same thing last name i'll save this and now if i refresh you can see i'm having two placeholders here i'll just remove this now below this button whatever data i insert inside input fields i want to display that one okay i want to display using php post method so here inside html also we can use this php syntax and here i have just returned that one and here i'll be writing this one if my server request i'll just write that one if my server request method whatever i am requesting if that method if it is equal to equal to post only then i want to get the data and i want to print the data here i want to get first name so i'll just create one variable you can give any variable name here this variable name is equal to dollar post okay because i'm using post method so i'll be writing this post method and inside this whatever name attribute you have given you just have to pass this one now this variable whatever i have created here f name now whatever i enter here this entire thing will be stored inside this variable f name now in the same way i just want l name i'll just make it as l and here i'll just make it as l now this last name will be stored inside the variable l name now once i get this data i just want to print that one i'll just do echo i want to print f name in the same way i want to print l name i'll just write l name i'll save this and also i'm just going to give your auto complete to be off so that i will not get any suggestions while i type autocomplete is equal to off so that my personal data will not be displayed to anyone i'll copy this and here i'll be pasting that one i'll save this i'll refresh once now here if i just write here sia and here if i write here uh i'll just write sharma i'll submit you can see i'm getting the output as cr sharma here okay this is how we are going to insert the data inside input fields and we are going to get the data okay this is all about post method post method is nothing but it is used to collect the form data once we enter the input fields once we enter email whatever mobile number once we enter that one this all data will be stored inside the database and from database we are going to fetch this one so for this post method is used it is used to collect all the form data and it is used to store somewhere it is an array of variables that is passed to current script and our current script is nothing but this 11 forms dot php through http post method okay this is all about post method now we are going to see more examples regarding this post and get now we are going to see about get method now here we are going to see about get method i'll just write here get okay now this get method is used to collect the data whatever is inside the url that is this is nothing but our url okay whatever parameters we pass inside url it is used to collect that one okay here we are going to see example here i'll be writing here href and inside this let me just give the file name i will be using the same file name so here i'll just write here i'll be writing here php and inside this i want the current path of the file so here i'll be writing here php server and that is nothing but php self now i want to execute in the same file so i am writing this one and inside this here i'll just write here click me i'll save this i'll refresh this one now you can see i'm having this click me once i click on this i'm executed in the simple you can see i'm redirected to same file now here below this one i'll be writing php syntax and inside this i just want to get the data whatever i have inside url so for that to get the data inside the url here i'll be writing one question mark and inside this i'll let me just write here subject subject is equal to php subject is nothing but php i'll save this i'll refresh once now when i click on this you can see after question mark i am getting subject is equal to php okay this get method is used to this get method is used to collect this data here okay whatever we are having inside this parameters that is used to collect this one here when i click on this you can see i'm redirected to 11 forms.php file and inside this i'm having this one parameter that is nothing but subject is equal to php now using that para use now i want to display that parameter so for that here i'll be writing here echo i'll be writing here this is i'll be concatenating this one and using this get method i just want to get that one whatever argument i have passed here i'll just paste that one here this is php let me concatenate this one i'll be writing tutorial i'll save this i'll just refresh once see now i am having here this is php tutorial directly i am having here if i just remove this entire thing from here i'll enter now you can see i am getting this undefined index subject in line php because here inside this url i am not having this subject as soon as you can see this tutorial has been printed so once i click on this you can see i'll be getting this is php tutorial inside my url i'm having this subject parameter and i am getting this output here this is php tutorial okay get method is used to collect the data whatever is present inside the url and it is also nothing but it is an array of variables which is passed inside the current script and it is used to get url parameters this is how we are going to get the data of the url parameters now what is get versus post now post is used to collect the form data and get is used to collect the url data everybody will be having when to use i'll just uncomment this and here i'll be writing one comment when to use when to use get and post now the data sent using get method will be visible to everyone because it is displayed inside the url and everybody can view the data so it will not provide much security but using post only the form data will be collected and this will not be displayed to anyone and we can send secure data and it will add more security we can send sensitive data using post method but using get method we can't send our passwords we can't send our email because it will be visible to everyone so post is going to add more security than get method and also get method is going to limit inside url we can't pass lengthy parameters so it is going to limit around maybe around 2000 characters it is going to limit but using post method we can send any amount of data there is no limit in sending the data so we should be very careful when sending our passwords and email we should never send our passwords or any sensitive data using get method we should always send using post method but sometimes if you want that data to be stored if you want to bookmark some data then using get method you can easily get the data and you can bookmark that particular page but using post method we can't bookmark because we will not be having any data so that we can remember in which page we have to go so using get method it will be easy for us to bookmark but using post method it's not possible to bookmark any of the content ok so the simple uses when you want to send sensitive data use post method when you don't want to send sensitive data and you want your data should be visible to everyone then you send that data using get method now i'll just explain one more example i'll just below this i'll just comment this entire thing now below this i'll be writing i'll just create one form and inside this form action let me just give the same file name i'll be writing here no let me just write here one i'll just create one file i'll be writing welcome dot php i'll be creating this file later on i'm just going to delete this now inside this i'll be passing this method is equal to post now here here i'll be creating input fields i'll be creating one more input field and i'll be creating one button here and for this button i'll be giving the type as submit now here below this i'll be adding br tags i'll refresh this now you can see i'm having this two input fields and button here i'll be writing his submit i'll save this i'll refresh this one now now below this i'll be writing this php syntax we have already seen this one how to get the form data i am just writing this one with my server request method if it is equal to post because method i have given as post now here i am just collecting the form data you can see fname and here i'll just give name attributes now when i click on the submit button this whatever i am having here that should be displayed in welcome dot php file so here i'll be creating one file i'll just give here welcome welcome dot php inside this file first i'll be writing basic snippet i'll be writing here welcome welcome page now inside this body i'll just create one let me just write here welcome and here i'll be writing php syntax and inside this i just want to echo whatever data i am having inside input fields i just want to echo that one and using this one i just want to get that okay i have stored the variable inside fname and also i just want to equate l name i'll just write here l name i'll save this i'll refresh this one here i okay i'm having here function name must be string on line 34 on line 34 so here we just have to write here square brackets i'll save this i'll refresh this now here i don't have any error and also i'm going to add auto complete here i'll refresh this and here first i'll be writing here seema and here i'll be writing here mehta once i click on submit you can see i'm having this undefined variable f name in this one and but here i am getting this welcome now here let me just remove this entire thing okay as of now i'll just comment this one it's better to comment this one and whatever i'm having here directly i'll be passing it here i'll just paste that one here and here also i'll be pasting that one and here i'm just getting the input fields okay directly i am printing that one i am not storing in separate variables directly once i click on submit whatever data i am having inside input fields i am just displaying inside another page i'll just refresh once now here when i write here i'll be writing khanam and here i'll just write here khanam khan submit you can see i'll be getting this welcome kanam khan okay this is how we are going to display the data inside separate file okay if you want you can do this one but it will it is very lengthy so directly i have passed that one here and this data whatever i am having here whatever i enter inside this input fields that will be stored here and that will be printed here okay in the same way we have done the same thing here this variable whatever whatever data we are entering that we are storing inside separate variable and we are printing that one okay you can use any of the method but this is how we are going to send the data from one page to another page using this post method and using get method also you can access this url data and you can display that one now that's all about php forms form validation we are going to see that one later and we are going to create separate series for that and we will understand how to validate form in php now here i'll just create one more file here i'll just write the file name as date.php now inside this file first i'll be writing php and here we will see what are the different formats of printing the date here i'll just write here echo now first we have this date and inside this year i'll be writing here month and finally i'll be writing here day okay now this is going to print the date in this format i'll just copy this path here i'll be pasting the path and from here i'll just remove this i'll just write here localhost i'll enter now you can see it is going to print the date in this format 2021 9 this is the month and this is the date i'll just copy another time and here i'll be writing one break tag now in place of this i'll just write here hyphen i'll just copy this and here i'll be pasting that one i'll refresh this now you can see i'm having different kinds of time okay now if you want to print the day i'll just write here echo and here i'll be writing date and here i'll just write l now this is going to print the current day i'll refresh this now you can see the current day is sunday it is going to print the day and if you write it is going to print the day and these are the different formats you can write when you are giving time suppose for copyright we used to write like this copyright and we will be writing 2010 to 2021 okay suppose imagine this is that here i i have written i'll just click enter you can see i'm having this copyright if i don't want to hardcode this value here i'll be writing here instead of writing like this i'll just write i'll be writing here php echo and here i'll just write here that and i want to get only here so i'll be writing it here i am not hardcoding the value directly i am writing that one i'll refresh this you can see again i'm getting the same output okay this is how without hard coding any value we can give the dynamic data and we can get the output using this date formats in the same way we have how to get the time suppose here if i just write here i'll just write here echo and here i'll be writing h h i'll write i and i'll just write here s a now this is for hours and this is for minutes and this is for seconds and whether it is am or pm i'll save this and also i'll just give one break here also i'll leave one break i'll save this i'll refresh this one now you can see i'm getting this output sunday but here i'm not getting the time because here i just have to write the date i'll save this i'll refresh this one now you can see i'm getting time i'm getting the day and also i'm getting the dates okay for copyright you can give this dynamic data and you can get the output okay this is how we are going to use date and time in php now we are going to see about how to include files and how to require files okay now if i show you an example here okay i have opened this amazon website and here if you see we have this beautiful amazon website and here if you see we have this menu bar if i just hover on this mobiles and once mobile page gets open you can see in this mobile section i am having the same header and if you notice this one i am having this footer here okay the same footer i will be having here whatever i have inside the home page i'll just come to home page now inside home page also you can say i'm having the same header and same footer there will be many things which will be common in all the pages okay here you can see i'm having the same footer i'll just come on top now again if i just hover to some other page like if i just go to electronics and here inside this electronic page also you can see i'm having same header and if i scroll down i'll be having the same footer you can see i'm having the same footer so for each page we don't have to write the entire code only once we are going to write and we are going to include in whichever page we need this one okay now we are going to see for each page we don't have to write the entire code we are just going to include that one now i'll just come here now here i'd be creating one file i'll be writing file name as home dot php now inside this file i'll just write here php here i'll be closing this php syntax now here inside this let me just write here one echo i'll be writing here include include files i'll just copy this path here i'll be pasting that path i'll just remove that one here i'll be writing localhost here i'm having this output include files now below this let me just create one in a basic boilerplate of html and here i will be writing here php include files now here i'll just create header i'll just close header i'm not getting suggestion so i'm typing this one now inside header let me just create one new year list and inside this let me just create here five list items now for each i'll just give your home here i'll be giving about here i'll just give here contact here i'll give services and finally i'll just give here featured features i'll save this i'll refresh this one now you can see i'm having this list items here suppose imagine that this is my header here i'll just write one h1 and here i'll be writing header header section we are going to see this example later but this is the basic you have to understand how we are going to include files now here i am having this header section you can see i'm having this header section now instead of this let me just add one anchor tag as well li i want five ls and inside each i want anchor tag so i'll be writing like this and for href first i'll be giving here home dot php now inside about i'll just create one more file about dot php now here i'll just write the headings i'll save this i'll refresh this one now when i click on home you can see i'm redirected to home.php now here i'll be creating one more file i'll just create one file i'll be creating here about about.php now inside this file about.php first i'll be writing this php syntax and here i'll just write here echo and here i'll be writing inside h1 i'll just write here about page about page i'll just close h1 i'll save this i'll just refresh this one now when i click on this about page you can see i'm redirected to about.php and here i am having this heading now inside this about page also i want this header whatever header section i'm having here that header section i want inside about page as well so i have to do the same thing i'll just come to home page now entire thing i have to copy like this this entire thing i'll be copying from here this entire thing i'll copy and here again i have to paste okay i'm repeating the code i'll save this i'll refresh this one now you can see inside about page also i'm having this header section okay each time we can't be writing the entire code and it is going to reduce the speed of our website okay and also it looks very ugly when we see repeated codes so to avoid this one i'll just remove this entire thing we are going to include files here okay now i'll tell you how to include here now here i have created this header now for this i'm just going to create one file i'll just give my file name as header.php now inside this header.php whatever i have written here i'm just going to copy this i'll cut from here and inside header.php i'll be pasting that one i'll just remove this comments i'll save this and now i have written this entire head section inside this new file called header dot php i'll just copy this file path and here i'm going to paste that one i'll just paste the path here and from here i'm just going to remove till here i'll be writing here localhost now here you can see inside this header.php i'm having the same thing inside about i'm having this header section but from whom i have removed now i want this header whatever i am having here that i want inside home page so here wherever we have to include that one wherever i want that one suppose here i have already written this one i'll just remove this now you just have to write this php syntax you have to write this include the keyword and whichever file you want to include you just have to write that file name header.php i'll save this i'll refresh this now you can see inside home.php i'm having this entire header section now if i click on home i'm having this header section now inside about us i don't have anything i'll come to about.php and from here i'm just going to remove this entire thing and from about home.php i'll just copy this line and here i'll be pasting that one i'll save this i'll refresh this one now you can see i'm having this up inside this about.php i'm having this header section when i click on home i'm having this one when i click on about page also i'm having this one let me just change the text here here i'll be writing echo about page and from header section i'm just going to remove this h1 and inside home page here i'll just do echo and here i'll be writing home page i'll just refresh this one you can see i'm inside about page now now when i click on home page i am inside home page now in the same way we can create contact us page services page feature space and we can include this header and we can use this header in any file and we can include any number of times now inside home dot php if i just include three four times i'll save this i just refresh this one you can see three four times it will be included okay we don't have to write the separate code for this we just have to write once and we can use many times here now here i'll be creating one more file i'll just create one file i'll write footer.php now inside this footer.php i'll just come to header.php and i'll just copy the same thing from here and here i'll be pasting that one i'll just remove this title and here i'll be writing include files let it be anything doesn't matter and from here i'm just going to remove this entire header and here i'll just write footer now inside this i'll just write one paragraph i'll be writing here copyright and we have already seen about dates i'll just write here 2010 and here i'll be writing this php and here i just want to echo the date i'll just write this one a code date and i want only here i'll just write y i'll save this now this footer i have to include inside home page now here i'll just remove this entire thing and below this i'll be including footer i'll just copy this and here i'll be pasting that one and instead of header i'll just write here footer i'll save this and in the same way i'll just copy this one inside about page inside about.php here i'll be pasting that one i'll save this i'll refresh once you can see i'm having this footer here okay inside home.php i'm having this footer and inside about us also i'll be having this footer okay this is how we are going to include files we have another statement that is nothing but required okay instead of include we can also use here required now here i'll just write here require i am it i am writing require inside about page i'll just write here required i'll save this i'll refresh this one now you can see i'm getting the same output then what is the difference between including and requiring inside home also i'm getting this output inside about also i'm getting this output when i require this particular file the basic difference between include and required statement is suppose inside include if i am including the file which is not present then it is going to generate error on that particular lines and rest all files and rest all code will be executed but in required if we require the file which is not present then it is going to stop the execution it will not execute the code now inside my file structure i am having this header.php file if i just write here header1 while requiring this one and inside home i am including this one so here if i write here h1 now this file is not present inside my file structure now i'll come here i'll refresh this one now you can see it is going to generate error inside this about.php i have required the files required header1.php fail to open stream okay it is going to generate this warning and error and whatever footer i was having that will not be executed i'll just come back i'll come to home page i'll refresh this one now you can see okay this is generating me this warning but footer has been executed okay that particular lines i'll be getting the warning but the rest code will be executed but using require i'll just come here but using require you can see i'll be getting this error and is going to stop the execution this footer is not been printed here you can see i have already required the footer as well but it will not be printed now here if i write include while requiring i am requiring the wrong file but i am including the correct file that is footer.php still i'll just refresh this one you can see i will not be having any output because here i am getting this error this require will stop the execution but include will not stop the execution you can see here footer has been printed here okay i am just having the warning but footer is printed okay this is the difference between include and require mostly we are going to use if you are making professional websites then we will be using required which means that that file should require in any case that file should be there inside your file structure or else we will be using include in all the projects okay that's all about include and require statement and that is the difference between include and require now next we are going to see php file handling now here i will be creating one file i'll just give my file name as 13 file handling okay file handling is very important suppose in your website if you have one text file if you want to read that file if you want to edit that file if you want to see that file then file handling is very useful and you have to learn the basic syntax of file handling how to open the file how to read the file how to close the file these are very useful when you make big projects using php now here i'll be creating syntax of php now first inside this now inside this first we are going to see about read file i'll just write here read the file while you're performing all the operations using file handling like you can create the files you can delete the files you can edit the files you can perform many operations in this file and while performing you should be very careful because if you are editing wrong file if you are deleting some of the important files then it will become messy and it is going to be difficult to restore the file so you should be very careful while editing and deleting the files so first we are going to see about read file read file is nothing but it is going to read the text whatever i am having inside the web now here i'll be creating one file i'll just give my file name as data dot txt okay this is the text file now inside this file i'll be writing some content i'll just come here i'll be searching for google google wiki okay that is google wikipedia i'll just come here i'll open this one now from here i'm just going to copy some content and i'll be pasting that one i'll just copy this one and here inside this text file i'll be pasting that one okay now here i'm having this text file now i want to read this entire text file so for that here i'll just write echo here we have to write this read file and inside this we just have to give which file we want to read i'll just write here data dot tech txt i'll save this now i'll just copy the path i'll just copy this file path and here i'll be pasting file path and from here i'll just remove this i'll be writing here localhost i'll enter you can see entire file has been written here okay whatever i have written inside this data.txt file that is been read by this one that has been read because of this statement and i am getting this output you can see i got this entire thing that i am reading this one okay this is all about reading files okay and this read file is important when you want to read the content inside the text file then it is very useful instead of using read file we have one more thing that is open i'll just comment this one now here we are going to see about open this is same as read file we are just opening the file and we are reading the contents inside that file but this s open will be very useful and this is going to add some more new functionality somewhere new features okay like reading like opening the file inside read mode in right mode okay it is going to add some more new features and it is very useful now we are going to see about this now here i'll just create one i'll just create one a variable i'll just give my variable name as my data and inside this i'll be writing this f open now here i want to open this data.txt i'll be pasting that one and this if open will take two parameters first what file should be open and second in which mode i have to open whether it is in write mode or it is in read mode okay here r means read and w means right so i will be opening in read mode i just want to read this file now here i just want to echo this now here i want to read this okay to read we have this f read it will take two arguments first i'm just going to pass in whichever file i'm opening i'm just going to pass that variable here by passing variables we don't have to enclose in double quotes or single cores i'll separate using comma and second parameter will specify maximum number of bytes to be read from that particular file so for that we have this file size and inside this one we just have to write this file name okay whatever file name we are opening will i'll just copy this one and here i'll be pasting that one i'll save this i'll refresh this one now you can see again i'm having the same output okay this is going to add more functionalities right we can have this read mode now this function is going to read the file which is opened okay which is open we are just reading that one and we are just getting the output now once we are opening the file it's always important to close the file okay now my file is opened and it's stored inside this variable i'll just paste that one here okay it's always important to close the file so that you will not be messed up with anything okay this is how we are going to read the file and we are going to open the file then we are going to read the file and then we are going to close the file i'll just come into this one now next we are going to see about f gets function now this function is going to read only the first line from that data file here i'll just write here echo i'll be writing here f gets and i want this file i'll just copy this variable and here i'll be pasting that one i'll save this now if i refresh this one you can see only the first line whatever i'm having inside this okay my first line is ending here okay you can see it's ending here this is first because here one two and three okay let me just give here my first line is still this one google llc is an american multinational i'll save this i'll refresh this one you can see only the first line will be printed okay it is going to read only the first line using this f gates we can read only the first line because suppose i want to print all the lines step by step or all the lines one by one i'll just give some breaks here i'll be adding some breaks okay now totally i am half okay here also i'll be adding some lines i'll save this and totally i'm having 25 lines and if i refresh you can see only one line has been printed now if i want all the data all entire file should be printed in the same order okay if i just give this one if i just give a freed i'll refresh this one you can see entire thing will be printed in only one paragraph i don't need this one i want whatever i have in whichever format i am having line by line i want that one to be printed so for that we are going to use another function that is end of file function and we are going to check if my end of file is reached till then you keep executing the lines now here to execute all the files we are going to write inside this and we have this end of file okay inside while loop we are writing until this condition fails we are going to execute the file now here i will be writing this variable my data which is opening the file and inside this i just want to execute this file i'll copy this one and here i'll be pasting that one and for each line i just want to add the break tag i'll just write here echo and here i'll be adding break i'll save this i'll refresh this one now you can see in whichever format i'm having the entire thing will be printed so whatever i am having here you can see after first line in second line is empty and 14 line is empty in the same way i'll be getting here second line i don't have anything and 14th line i don't have anything and this is how it is going to print okay we are just checking the condition until the end of file until the end line is reached till then you keep executing this one once my file is reached then stop executing and come out of this loop and close the file here if close is the function to close the file okay this is how we are going to check for each line and we are going to get the output now we have another function that is f gets now here i will be writing that one here i will be writing f get c now this function is going to return character by character now instead of this f get s i'll just write here get c i'll save this i'll refresh this one now you can see character by character i'll be getting the output first i got the output as google second i'll be getting llc okay i'm giving inside this while loop so i'm getting this data in first line i first it is going to return the first output that is first g second it will add break again it will return o again o then g then l then e okay it is going to return character by character so we have this get okay this one f file get c that is it is going to return character by character okay this is about handling files okay we have seen how to read the file how to open the file how to read that content how to close the file how to get first line how to get the output character by character and how to get entire data using while loop and this called as end of file and this is how we are going to close the files now next we are going to see how to create the files and how to write the files okay we have seen about reading the files now we are going to see how to write the files and how to create files how to create new files inside this code itself now here i'll just comment this entire thing we have seen about reading files and opening files now we are going to see about how to create files create and write files now below this okay we have already seen we have seen this one how to open the file using this f open function and this f open function is used to read the files and also it is used to create the files okay it is confusing but okay when this file is already present then it is going to read the file then it is going to show that file if this particular file is not present inside my file structure then it is going to create that file so here what i will be doing is now first we are going to see if open this function is used to read the files and also it is used to create the files now here i'll just create one variable i'll give my variable name as my new file i'll just write here my new file and inside this i'll be writing this f open function and inside this let me just give my file name as i'll be giving my file name as php.txt this file is not present inside my file structure i'll be opening in write mode i'll save this and also i'll just echo this one echo i'll be echoing this my new file i'll save this now you can see inside my file structure i don't have this php.txt file you can see i don't have this one only i have this data.txt file i'll come here i'll just refresh this one now i am having this one now if i show you my file structure you can see here php dot text has been created for me okay this entire file has been created for me this s open function it is used to create files if the file is not present then it is used to create if the file is already present then it is used to open okay now i have created the file i'll just comment this one now here i want to write some text inside that file so here i'll just create one variable and inside this variable let me add my name khanam now i want to insert this string inside that php file so to insert that now for reading this file we have this f read now for writing we have f write i'll just write here f right and i want to insert this particular text in this file okay i have already created this one i'll copy this file name here i'll be writing that one and i want to insert this text inside that file and this is going to take two parameters first is the file name and second what text should be entered what string should be entered inside that file i'll save this i'll just refresh this one now here if i show you inside this php.txt you can see khanam has been added here okay if i add something here if i add here kandam coding here i'll be adding this is new tutorial i'll save this i'll come here i'll refresh this one now if you see inside this one you can see entire text has been added here kanam coding and this is new tutorial ok this is how we are going to write the text and we are going to create the text files now again if i just i'll just copy the same thing i'll be pasting that one here i'll be writing here step by step i'll just remove this and here let me just write here step by step now again i'll write the file i'll copy this one and here i'll be pasting that one i'll save this i'll refresh this one now if i show you inside this php.txt you can see whatever i have written it is going to write that one okay khanam coding this is new tutorial and again i'm having step by step this is new tutorial okay this we can add as much as strings we want and we can write that whatever we are having we can write that inside our files okay this is all about creating files and writing inside the files and we have seen how to open the files and how to read that particular content okay that's all about handling files in next session we are going to learn about cookies now here i'll be creating one new file i'll give my file name as 14. i'll just write here cookie dot php now cookies are nothing but it is used to store the information inside our system now suppose if you are visiting some website and if you are searching for food that food will be stored as a cookie next time if you visit that website only food category will be shown to you okay if you can search for any category as well but food will be shown on top okay if you are using instagram and instagram if you search only for artist if you search only for drawings and paintings in your home page only drawings and paintings will be shown okay because one cookie will be set and that category will be set to drawings and all the drawings and paintings will be stored okay and cookie is nothing but it is a piece of information that will be stored inside our system inside our system itself it will store it is not going to store in any service so while you are using cookie you should be very careful that you should not store any username and password because username and password we are going to store using sessions we are going to see sessions in our next session but using cookie we can just store the category and it will be safe if we store only category it is unsafe to store the username password email and this cookies will be stored inside our system itself so we are going to see an example and you will understand what is this cookie and why we are using this cookie if you have noticed in whenever you visit website they will ask set cookies okay that is nothing but we are going to see this one how why they are asking that and why it is useful to use cookies and while we are setting the cookies i'll just write one comment here i'll be writing here cookies okay this comment what you are saying this is html comment because we have not yet written php syntax so this is called as html comment now i'll be writing here it is a piece of information stored inside the system and here i'll be writing we should never store username and password using cookies now this is the definition for cookies it is just a piece of information that will be stored inside our system and we should never use any username and password to set the cookies now here i'll be writing php syntax now first we are going to see the syntax of how to set cookies here i'll be writing syntax now below this using this set cookie function we are going to set the cookie okay here we are having this set cookie you can see whenever i hover on this it is taking that first parameter string you can see here first it will take string name then it will take the value then when it expires when my string should expire then it is going to take the path domain boolean okay this all are not important but name value when it expires and path what we have to give we are going to see only this parameters rest all you can ignore these are optional okay now inside this first it is going to take the name what category or what you want to see next it is going to take the value suppose if you are writing food then in food you are searching only for biryani okay biryani will be the value and name that will be food and when it expires it will take that one and finally it is going to take the path okay rest all parameters you can ignore that one like you can see you can ignore this boolean domain name all we don't need this one we are just going to focus only this four parameters but this or four are also optional only name is very important now below this we are going to write one example now here suppose you are visiting some online food ordering website and they they are setting some cookies now here i'll be writing here set cookie and inside this okay before that i'll just create some variables i'll be writing here category name i'll just write here category name category name let me just add here food i'm searching for food and category value i'll be writing here uh biryani okay you love biryani and you are searching only for biryani i'll just write here category value now first parameter i'll just copy this one and here that variable should not close in single quotes or double quotes this is just a variable my category name is food now next i'll be passing value i'll copy this one here i'll be pasting that one next when it should expire so first we have to write this time whatever time we are having we are just writing the current time plus when it should expire so in one day we are having totally eight eighty six thousand four hundred seconds we are just telling that in one day it should get expired whatever we have set in one day it should get expired you can give any seconds here this is nothing but 86 400 second is equal to one day now next we are going to set the part where we want to set the cookie i want to set the cookie in the entire website so i am just writing this slash okay we are setting cookie in entire website now here i have just set the cookie i'll save this i'll copy this path and here i'll just write one echo i'll be writing here cookie is set i'll save this i'll just remove this localhost i'll just remove till here i'll be writing here localhost i'll enter you can see cookie is set now to see where our cookie is set inside our system you just have to inspect this one and here you are having many tabs like elements console source you have to come to applications and inside this application you can see you will be having your cookies on my right side you are having these cookies and inside this one you can see the cookie has been set food category is food and value is biryani okay this they are going to see the local host okay this is a domain and path is nothing but slash and it expires within one day it will give the time okay here you will be finding this cookie okay now this cookie has been set and this is set inside our system itself you can see food and biryani now when i enter some other request this cookie is already set inside my system now we are going to see how to get that one now here instead of creating separate variable and passing this one directly we can give like this food and next parameter is value i'll just copy this biryani from here and here i'm going to paste that one i'll save this i'll just refresh this one now you can see this has been set now this it will take complete one day to be expired now let me just create one more file now i'll now i'll just create another file i'll give my file name as 15 i'll write here get cookies get cookies php now in this file whatever category i have set i want to get that one now here i'll be opening this php file now we are going to get cookies here so here i'll be creating one variable i'll be writing here my data and inside this we are just going to get cookie so we have to write this cookie and what name i have set i just have to write that one here i have set as food so i'll be writing food here because inside cookie you can see my name is this one okay this entire thing you have to write i'll just comment this variables whatever you write here the same thing you have to get one okay you just have to write here now i'll just echo i'll be writing here i am new searched that is and here inside this i'll be writing this variable i'll save this i'll just copy the path and here inside this new tab i'm just going to paste that one i'll remove this i'll enter you can see i am newly searched category and that is biryani okay this is going to give me the value what i have searched now i am just giving i am passing my cookie name that is my category name food and it is going to return me the value whatever i have stored inside this one okay it is going to return me the value and my category is food and it is going to return me biryani as my output and my searched let me just write here searched item is searched item is biryani i'll refresh this you can see i'm newly sold item is biryani i am new searched item and i am biryani i'll just write this one i will refresh this now here i am having this output now suppose i am just setting the cookie here now here if i just give here three that is i am just setting the cookie and it should expire within three seconds now i'm just telling that within three seconds this cookie should be expired now here i'll be writing category and here category let me just write here gadgets i'll save this i'll come to this file i'll refresh this one now you can see inside this i'm having this category and gadgets is also been stored you can see inside this category and gadgets store and this is my another cookie that is food and biryani i'll close this now 3 second got over i'll inspect this again now inside application inside application inside this cookies you can see only food is been stored because it it will expire in one day but that category has already been expired because i have given only three seconds here okay this is how we are going to set the cookies we are going to get the cookies and we are going to give the time when it going to expire okay if you want to give like if you want to expire i'll just give you 86 400 seconds this is for one day if you want this cookie to set for two days you just have to write here into just uh close in parenthesis like this you have to fight okay this will expire in two days okay this is all about setting cookies and getting cookies and cookies is nothing but it is a piece of information that will be stored inside our system okay now next we are going to see about sessions and finally we are going to make our project now finally we are going to see the last topic for the day that is nothing but sessions and after sessions we are going to make complete dynamic website using php and we are going to apply whatever concepts we have learnt till now now here i'll be creating one file i'll just give my file name as 16 i'll just give here sessions.php now sessions are nothing but they are used to store the information suppose if you are logging in inside facebook and you after visiting facebook if you come outside and again if you go and visit facebook you don't have to log in again unless and until you log out from facebook so this is where sessions are useful okay when we are using some websites our system will be knowing what we are searching for but server will not have the data which user is using that particular website or anything so that problem is solved using sessions and sessions data will be stored inside server and from server we are going to access that one and that data will be stored inside servers if you are logging inside facebook and if you log out again when you go to facebook you have to log in again once you log in you can use facebook and your entire login details will be stored inside facebook okay again if you want to visit you don't have to login again you can directly use facebook and you can start looking the post okay this is where sessions are useful and it is mainly used in registration system that is nothing but a login systems now here first i'll be writing this php syntax and here i'll be writing one comment i'll be writing here sessions it is a way of storing users information now to use session first we have to start session we are going to start session like this you have to write a session start once you start this one our sessions will be started and we are going to create session variables now session variables will be created like this you just have to write this dollar symbol and we will be writing this session and inside this we are going to create variables okay this is called as variable name in session i am just storing username username i'll just give you a khanam and i want to store one more variable i'll just come down i'll just write here session and here i want to uh store password now here password i'll just give here coding okay i have i have created two variables username and password and username i have stored as khanam and password i have stored as coding now below this i'll just create i'll just write to an echo and inside this i'll be writing here session session data is saved i'll save this i'll save this i'll just copy this file path and here i'm going to paste that one i'll just remove this i'll be writing here localhost now you can see i'm having here session data is saved now this data is not saved inside the system this data will be saved inside server now here i'll be creating one more file i'll just give my file name as in information information dot php now inside this file i want to get whatever variables i have stored using sessions i want to get that variables inside this file okay to use session variables here also first we have to start session we have to write this session start okay this session start is nothing but it is built-in function in php and it is mainly used for login information let me just close all the files now inside this sessions.php i have two variables username and password now whatever value i am having here that i want to get inside this page inside this information.php now here i'll be writing echo first let me just write here welcome i am just going to concatenate this one i will be writing this session variable and my session variable is nothing but first i want to tell welcome username whatever user we are entering we are just welcoming that username and next i just want i don't want to display password but as of now for this example i am just going to display the password and your password is and also let me add one break here i'll just write here password i'll save this i'll just copy the path now here i have already set that variables now i am just going to remove this i'll enter you can see welcome khanam and your password is coding okay once we set the session variables we can access that variables in any page you can see i got the output here welcome khanam and your password is coding now we can store email as well i'll just write here email and here let me just write here coding at gmail.com this whatever we are creating that is called as session variables now inside this i'm just going to write the same thing i'll just copy this and here i'll be pasting that one and your email is here i'll just write email i'll save this i'll first come here first i'll set that one now email will be saved i'll refresh this one and your email id is okay we will be getting this output okay using sessions we are getting the data directly from the server and we can use this data throughout our website or throughout our app okay this basically it is used in login system so let us create our logout i'll just create one logout.php now inside this file we are going to unset all the variables and we are going to destroy all the variables now here i will be creating php once we click on logout all the username and password we it will be removed and again we have to in so we are just going to do that one so first we have to start the session here and to destroy that one first we have to unset so here i'll be writing session we have this session unset now this is going to unset all the values now finally we have to destroy that one all the variables we have to destroy we have another function session destroy i'll save this i'll just copy the path and here i'm going to paste i'll enter now all the variables okay let me just write one echo variables destroyed i'll save this i'll refresh this one you can see now variables are destroyed now if i come here information.php i'll enter you can see i'll be getting this error okay undefined index username is not set password is not said and email is not set again i'll come here again once i click on this now this session will be saved now again if i come if i refresh this one you can see again i'm getting this welcome khan again i'm logging in here all the data will be stored again once i refresh this one i am log out now if i just try to log in you can see i will be getting this error now again i am logging in again i log in you can see i am getting this output again i log out all the data will be erased from here you can see this is how we are going to use this is the simple login system i have already created simple registration and login system you can check for that but this is how we are going to set the variables using sessions once we login okay here i'm just logging in and all the variables will be set now here all my information is stored okay you can see kanam password and email has been stored now this is my logout page once i log out of this all the variables will be destroyed and now i will not be having any access to that particular variables okay i'll be getting this password is not their index is not their username is not there okay this is how we are going to create but this warning we don't want to show this to the user okay we want some message to be shown so for that inside this information.php here i'll just check the condition if is said i'm just telling that if my session variables are set only then i'll just write this one session if my session variable username if my username is set only then show this entire output else i just want to echo please login again to continue i'll save this first i'll come to this sessions.php i'll enter now all the data will be stored i'll refresh this one now here i'm having all the data all the variables kanam password and email again i'll log out from here again if i come here i'll enter you can see i'll be getting this please login again to continue i will not be having any error now but i will be getting this message please login to continue again i'll come here i'll save all the variables now if i enter you can see all the variables will be stored now again if i log out the variables will be destroyed and here i'll be having this message please log in to continue okay this is how session variables are very useful it is used to store our information without logging in again and again we can use our information by directly going inside our website once we log out again we have to login and we can start using the website cookies data will be stored inside a system but sessions data will be stored inside server using sessions will be more secure than cookies that's all about sessions now finally we are going to make one complete dynamic website using php okay that will be our final project in this tutorial finally we are going to make project using php whatever concept we have learned till now we are going to apply almost all of them and we are going to see about php my admin dashboard that is how to use database in this now you can see i am having this header okay i have used bootstrap here if you are not aware of bootstrap then you don't have to worry about bootstrap we are just going to use some basic things from bootstrap so i'll be telling you from the scratch so you don't have to worry about bootstrap if you are not aware of that here i have one heading welcome to our store and here i have another heading shop by category below this i am having here total six cards you can see i'm having this first card second totally six cards i'm having here now when i click on this card okay you can see i'm having this image if i click on first card i'm having this orange image this amazing frock headings and some text here and i'm having the price now when i click on continue reading you can see i am having completely about that frock you can see entire data will be stored and here i am having this continue to shopping button and below this i am having this image and here i am having some text i am having the price and here i have this add to cart button now again when i click on this continue to shopping here i have this second card blue gone i'll just click on this here you can see i will be getting that image i'll be getting this heading price and this add to cart button again i'll just come to continue to shopping if i just click on this stylish dress you can see that particular image i'll be getting here i'll be having this paragraph container and here i'm having the stylish dress whatever data i am getting this data i am getting directly from the database i have not hardcoded any values directly from the database we are fetching this data and we are displaying inside our website this kind of websites will be very useful when you are making e-commerce website and when you are planning to make your website using php as a back-end then this is very useful for you to know this section okay how to use this section and how we are going to create this one now if i just click on this you can see this particular image this entire text about the image this heading and here i am having this price so whatever price i have given here here you can see two thousand rupees that will be displayed here okay that will be displayed and we are going to add to cut now we are going to create this project and here if you see using this id and we have seen how to get this id and we are going to get this id using get method using that get method we are going to display this entire data okay now we are going to create this project completely from the scratch now here if i just come here you just have to type here localhost slash phpmyadmin and you will be redirected to this phpmyadmin dashboard and this is nothing but a database on left side if you see here i have created many databases by default you will be having maybe around five databases but this all databases you will not have i have created this one so inside my php my admin dashboard i am having this databases but you will not have this one here we are going to create one new database we are going to create tables and from that table we are going to fetch the data now let's get started with creating database now here you will be finding this new just click on this new and here they will ask for the database here i'll be writing here e-commerce e-commerce website click on create see database e-commerce has been created now on my left side you can see e-commerce website database is com e-commerce website database has been created now here once i click on this it will ask me to create table here i'll be creating table let me just give the table name as i will be giving the table name as clothes okay you can give any table name for id i need one column second i'll be having this image this image also i'm getting directly from the database i am not hardcoding anything here third is for my heading fourth is my paragraph and fifth is my price okay totally five i five columns i need here i'll just give five i'll click on go if we want extra columns we can add later but as of now i need only five columns here i'll be giving here category id here i'll just give category name here i'll be giving category description here i'll give category price and here i'll just give category image from database i'll be fetching all this data and i will display inside my website now for each column we have to give the data type for id let it be in for category name i'll give varchar and size i'll just give 255. maximum is 255. you can give anything here from 0 to 255. description i'll just give here text and size i'll give 255. price i'll just give in float here you will be having this float size i'll give 10 comma 2 2 is nothing but after integer how many decimal points i need for category image i'll just give varchar and size i'll be giving here 255 and for id category id i'll just i'll make it as primary so that i will not be having any duplicate values i'll just click on this auto increment and here i'm having this primary key now this primary key will uniquely identify this particular id from the database okay now i'll just click on save it's processing now if you see my clothes table has been created and here i have this category id here i have this key which means that i am having primary key for category id i have category name category description category price and category image for each i have given the data type and also size you can create database directly inside php code but using phpmyadmin dashboard it makes us easier to make databases creating tables inserting data updating data okay it will become very easy for us i will be uploading about php databases but here we using this php my admin dashboard we are going to create everything okay i have given uh i have this typo error instead of clothes i have just given your cloths okay no problem you can just give claude if you are doing exact same thing then you can just give c l o t h e s now once we are done with creating table creating database now let's get started into the course and start writing the code and start making the project wherever you have installed xampp come to that folder inside that you will be finding this htdocs folder open that and here i'll be creating new file i'll just click on new folder i'll just write here folder name as e-commerce i'll open this folder i'll right click on this and open with code i will be pasting images folder here now this folder will be opened you can see here i have this welcome page here i'm having this folder now here i have already pasted images here you can see i'm having this images folder here inside this i'm having all these images cloth one cloud two clue three okay all these images i am having inside this images folder now this entire images we are going to store inside database and most important thing when you are starting apache you have to start my sql as well to connect to database okay whenever you are using database then you have to on this mysql database and also apache will have to start because we are running php in browser so we have to start this apache which will be acting as a local server and mysql for database we have to on this one i'll just close this now here we are going to create our first file i'll just create one file i'll just give here index.html now inside this file we are going to set up basic structure and then we are going to start with our project i'll just come here and here i'll be searching for bootstrap you can see i'll search for bootstrap and inside this i'll just click on this first link okay here you will be having this getbootstrap.com i'll just click on this and here you will be having this get started i'll just click on this get started button now here i'm having the css link i'll just copy this one we will be using bootstrap here okay so that we are not going to waste our time in css now here first i'll be writing this basic boilerplate of html i'll just change the title to e-commerce website and below this i'll be writing one comment below this i'll just write one comment i'll be writing here bootstrap css link below this i'll be pasting that link and from here till integrity i'm just going to remove okay we don't need this part only so much is enough now here i'm just going to write one h1 i'll be writing here e-commerce website okay later on i'm just going to remove i'll save this okay i'll just copy this file path and here i'm going to paste that file path and from here i'll just remove this i'll be writing here localhost now here you can see i'm having this heading e-commerce website now this is my database and i'll just close this bootstrap later on i'm just going to open now to use a database first we have to connect inside a database so for that here i'll be creating one folder i'll give my folder name as partials because i'll be using header in both the pages here if you see my project this is my project and here i'm having this navbar header and when i click on this continue to reading inside this also you can see i'm having this header two times i'm having this header so i'll be creating one partials folder inside that i'll be creating header file and that file i'm going to include in both the files now here inside this partials first i'm just going to create one file i'll be giving one connect dot php file now inside this file i'll be writing the code to connect to database we have not seen about php database but in this tutorial you will understand you will just get a basic idea of how to connect to database and how to insert the data inside the database now here first i'll be writing this php syntax now here i'll just create one variable connection and inside this i'll be writing this new mysqli and here inside this first i am just going to pass this local host localhost is nothing but a server name next i'm just going to pass the username whatever username i'm having inside phpmyadmin dashboard i'm just passing that one next i'll be passing this password by default if you have not changed it will be empty i have changed my password so i'm just giving whatever password i'm having next i'm just going to give the database name whatever i have created my database what i created was e-commerce website i am just going to write that one now here i will just check the con i'll just write one condition if my connection is successful then i just want to print this one i'll just write here connection successful connection successful else else it should show me an error i'm just going to write this die and here i will be writing this mysqli error mysqli editor function i'm just passing this by mysqli error function now here i'm just going to copy this file path and here i'll be pasting the path i'll just remove from here i'll be writing here localhost i'll enter now i am getting this warning unknown database ecommerce website okay i'll just change the spelling ec e-commerce i'll save this okay this is the error i'll refresh this one now here i'm getting this connection successful which means that i am successfully connected to my database okay whatever database i have created here e-commerce website i am successfully connected to this database now i can use these tables i can insert the data i can delete the data i can update the data i can do whatever i want in this database now here i am successfully connected now this file i have to include inside this index.html okay i'm just going to change to index.php here i'll just come here and here inside this i'll just rename this file i'll be giving index.php now from here i'm just going to remove index.html i just give it php okay now here i'm having the same output once i'm successfully connected to my database first i'll be working on header now inside this partials folder itself i'll be creating one file i'll give my file name as header dot php inside this file first i'll be writing this basic boilerplate of html and from here i'm just going to remove this i'll just write here ecommerce website now from inside index.php i'll just copy this bootstrap link and here i'm going to paste that link now below this below body i'll just come to bootstrap website now from here inside components here you will be having this nav bar click on the snap bar and here you will be having multiple nav bars i'm just going to select this first one i'll copy this and here i'm going to paste that one i'll save this and here i'll just copy this file path and if i show you the output i'll just remove this i'll be writing here localhost now you can see my navbar has come here i will be changing some styles now inside my project i am having a search bar so for that let me just remove this drop down from here i'll just remove this entire drop down and also this disabled button i'm going to remove i'll save this i'll just come here i'll refresh this one now here i'm having this one we are going to fix this now here i'll be writing about and from here i'm just going to remove this current and also inside this href i'll be giving here index.php index.php file i'll save this and from here i'm just going to give here details.php details.php i have not created so here i'll be creating that file i'll just give my file name as details.php now from here as of now i'll just remove this uh basically we don't need that one we can fix that one you just have to give some margin left and right and it is going to fix but here i am having this nav bar now for this snapper first i'm just going to give some padding inside this let me just give some padding give her padding excess three i'll refresh this now here i am having some space now once we are done with creating our header i will just come to index.php file now here i am just going to remove this now here first i will be including connect.php so that i will be connected to database and to include files we have already seen we just have to write this php syntax and here i will be writing this include and inside this partials folder i am having this file okay that is nothing but connect.php file now in the same way i have to include header as well and instead of connect i'll be writing here header i'll save this i'll just come to index.php file this is my index.php file i'll refresh this one now here i'm having this connection successful and my header okay each time i don't want to print this connection successful so i'm just going to remove this i'll just come here and here i'll just change the condition if i am not connected successfully then show me this error okay i'll just remove this connection successful and from here i'm just going to remove this else part okay if i am connected successfully then i will not be having any error if i am not connected successfully then i will be having some error okay basically i am just checking the condition if i am not connected then show me this error now if i refresh this one you can see that connection successful whatever we were having that will go now here from this i'm just going to close this header.php as of now i'll be closing this database once we are connected to database and header now here first i'll be writing one h1 and for this h1 i'll be writing here welcome to our store i'll just come here i'll just copy this text from here and here i'm going to paste the text i'll save this i'll just refresh this one now here i'll be having this heading welcome to our store we are just going to give some bootstrap classes here i'll be writing class and for this first i'm just going to give a text center so that my text will come in the middle and also i'll be giving the color text primary so that my text will be in blue color and also i'll be giving here margin bottom i'll save this and now if i refresh this one you can see i'm having this heading here now next i'm having this heading i'll just copy this one and below this i'm just going to create another h1 and for this h1 first i'll be giving the class name as text center and also the text color i'll be giving here success and from bottom i need some margin so i'll be giving her margin bottom to be 4. inside this i'll just paste that text i'll come here i'll save this now you can see i'm having this heading now next i am having this six cards here you can see six cards so inside this bootstrap i'll just come to cards here you can see i'm having this card on my left side i'll just click on this card and inside this you will be having plenty of card components okay you can select any one of this whichever you feel you are comfortable you can just select any one of the card you can see if i scroll down you can see i'm having this multiple cursor with image without button here i'm having with button i want this one first one i'm just going to select this i'll just copy this one now below this h1 first i'm just going to create one diff and for this div i'll just give the class name as container okay these are bootstrap classes if you don't know if you are not aware of this classes then no problem you can still learn bootstrap now inside this container first i'm just going to give a diff and for this i'll just give the class name as row so my all the cards will come on side by side inside this row first i'll be creating diff i'll be giving here i want to make it responsive as well so in my medium screen divisor i want totally three cards should be displayed so here i'm taking four so next column i'll be taking for another column i'll be taking first so totally too well i'll be having here i'll just give here call sm for smaller screen i want six six six totally i want in small screen i want two two cards and finally in my extra small devices i'll just write here xm and in this i want complete to well okay which means complete one card will be displayed and also for each card i'll be giving some margin bottom so that my cards will not get stuck now inside this i'll be pasting that card whatever i have copied i'm just pasting that one i'll just format the document okay now first i have just created one div with the class name container inside this i'm having this another diff with the class name row and inside this row this is my first column which is having the card okay here column medium screen i have given four totally it should end up with 12 this is my first card for second card i'll be giving the same value and third card i'll be giving the same value so so totally i'll be having twelve four plus four plus four twelve for smaller screen devices i am just giving here 6 and for extra small devices i am just giving 12 which means that complete one card and also i am just giving margin bottom so that i will be getting some space from below now inside this i have just pasted the card i'll save this i'll come to my project i'll refresh this one now you can see my first card has come here now in the same way i want second card let me just change the image i'll just give it images path and inside this i am having let me just give here float1.png i'll save this i'll refresh this one now you can see my first image has come here now by default we are having some style okay for this we are having some with i'm just going to remove that with i'll save this i'll refresh this one now here i will not have any width now this is my first card i'm having image card title text and some button i'll just copy this entire diff i'll just copy this one and below this i'm just going to paste second card third card fourth card fifth card sixth card i'll save this i'll refresh this one now you can see totally i am having six cards i don't want this data should be displayed i don't want the static data whenever i you can see i'm having this data which is displayed directly from the database so in the same way i want the same data here i don't want this kind of images i don't want to repeat my entire code okay like this i don't want to do so this entire cards whatever i have written i'm just going to comment everything it's better to remove and i'll just give only one card i'll just remove all the cards and here i'll be keeping only one card i'll save this now if i refresh this one you can see i'm having only one card now i'll be working on this card i'll just open this card and for this image i'll just give some inline styling i'll just write here style and inside this i'm just going to give the height for the image height i'll be giving 300 pixel and also i'm just going to give object to be content so that my images will not get squeezed object fit i am just going to give here content okay now this is my first card now below this row below this class is equal to row we are going to write php code here before that we have to insert the data inside the database so for that i'll just come here i'll just close this one now i don't need that one here i'll be writing localhost php my admin dashboard i'll just come to e-commerce website and this is my clothes table i will just open this one and here i'm going to insert some values here you will be having this insert option i'll just click on this and category name i'm just going to give this one amazing frogs i'll just copy this and here i'm going to paste that one and i'll just click on continue reading i'll just copy this entire text from here i just copied this text from google i'll just paste the description here and inside this price whatever price i'm having i'll just copy this 800 and here i'm going to paste 800 and for images path whatever images path i have given here this entire thing i'm going to copy and here i'm going to paste that one okay dot slash images folder and inside this i'm having float1.png i'll just click on go okay now this entire data will be inserted and if i show you the table now if i just come to this table clothes and here you can see the first data has been inserted amazing frogs and this entire data has been inserted in the same way i'm just going to insert the data for second third fourth fifth and sixth data all the data i will insert and later on i'm just going to come now you can see here i have inserted all six datas i have category id category name description price and image okay all the things i have stored inside the database now from database i'm going to fetch using php and that data i'm going to display inside the website now below this row wherever i have written this php code comment and here i'll be writing this code okay now code we are going to start now first i'll be opening this php syntax i'll just write here php i'll just close this php here now inside this php first i'm just going to select all the data from the database so for that i'll be writing one query i'll just write here sql for selecting all the data we have this select star from data star means selecting all the data select star from table name okay my table name whatever i have given here inside the database that is this one c l o t h s i'll just write that one here c l o t h s okay from this table whatever data i'm having inside this table i'm just selecting all the data now i'll be executing this query i'll just create one variable result and inside this i'll be writing this one mysqli query this is used to execute this query and inside this i'm just going to pass two arguments first it will take connection variable this connection variable we have created inside this connect.php file you can this variable whatever you have created i'm just passing that one and second variable it will take this one i'll just copy this one and here i'm going to paste it is going to take two arguments first is connection and second these are query variable now here i'm just going to check the condition if my result that is if my query is executed successfully then i want to fetch the data from the database okay now let me just create one variable row and inside this i'll be writing this one mysqli fetch asic and this is going to fetch only first data from the database and my data is stored okay my query is here inside this result variable i'll save this now i'll just come here i'll refresh this one now here i'm not having anything let me just print that one echo i'll be writing this dollar row and from database i just want to get this okay let me just get this category name i'll be writing this category name here i'll just write here i'll save this now if i show you the output you can see i'm getting this amazing frogs okay whatever data i am having inside the database first data i am getting here and i am printing here but i want entire data whatever i have inside the database i want entire data should be printed one by one so for that we are going to use while loop and using while loop we are giving the condition in such a way that once my all the data is displayed while loop will get filled and it will come outside the loop now here instead of writing like this i'll just comment this one now below this i'll be creating while loop and inside this while loop i'll be passing this one so whatever i have created this i'll just pass that inside while loop so it will be executed for each line and the card will be printed now inside this while loop first i want to get whatever id name i'm having first i'll just come here whatever id name i'm having category name category description okay entire thing category price category image i want to fetch that one and i will be storing inside separate variable now here first i'll be creating category id i'll just create one variable this is my variable name you can give any variable name here i'll be writing this row and inside this okay whatever name i am passing here that should be matching with the database column name okay now here i first i want to get this category id so whatever name i am having here category id that should be matching with this i'll just write here category id in the same way i'll just copy this one now next i'll just create one variable i'll give category name and here also i'm just going to give your category name okay variable you can give anything next i'll be giving category description and here also i'll just give a category description and here and here i'll just give here image and finally here and here i'll be giving price now this data whatever data i'm having inside the database i'm fetching that one like this and i'm storing inside this variables now these variables will be having all the data now i'm just going to do echo and inside the single course whatever card i am having here this entire diff container i'll copy this one i'll cut from here inside this i'm just going to paste that one and also i'm just going to close this and from here i'm having this single quote i'll just remove as of now i'll save this now if i show you the output i'll refresh this one now you can see total six cards i am having because total six data i am having inside the database so complete total six cards will be displayed my image my title my text everything is same because i have hard coded this value i have not written dynamic content for this i am just hard coding this value so i am getting that data now instead of this suppose if i add one more data inside this one then i will be getting six cards here okay i have passed only one time you can see i have passed only one card inside this echo and it is printing sixth time because it is going to run this while loop again and again unless and until this condition gets failed if i am not having any data inside the database then it is going to stop and it will come outside the loop now i will be writing the dynamic data here now instead of this src image i'll just remove this instead of this i'm just going to concatenate this variable okay i'll just copy this variable from here and here i am going to paste that one i will just concatenate this i save this now if i show you the output you can see here all the images has been changed okay here i am having this images and all the images are changed now now next i have to change the title i'll just remove this title from here i'm just going to concatenate and inside this i'll be writing here image category name i'll just copy this one and here i'll be pasting that one i'll save this i'll refresh this one now you can see i'm having all the title has been changed next i have to write the description i'm just going to remove this entire description from here i'm just going to concatenate this and inside this i will be writing this category description i'll just copy this one and here i'm going to paste that one and here i'll just create one paragraph and for this paragraph i'm just going to give the class name i am not going to give any class name i'll just close the paragraph and inside this i want to concatenate category price i'll just copy this one and here i'm going to concatenate i'll save this i'll refresh this one now you can see my text i am having here my entire description my price and everything i am having here for price i i just want to give here slash so here after this i'm just going to give like this i'll save this this one i have just given so that it will come in price i'll refresh this now you can see after prices i'll be getting the slash and hyphen okay but you can see here the content is very large and it's looking very ugly you can see for this images has gone here for this buttons have gone here but here if you see here my content is like this okay only some 50 to 20 characters i have displayed and here i am getting this once i click on this this entire data will be displayed here so for that i am just going to give instead of this here i'm just going to write here substring and here inside this function i'll just wrap this inside this function this is going to give this category description i want to show from 0 and around 55 characters and after that i just want to show this dot dot dot after this single quotes i will be writing this dot dot i'll save this now only 50 characters will be showed i'll refresh this one now you can see only 55 whatever number i have given here only that many characters will be shown here okay you can see only 50 and then i am having this dot dot dot now when i click on this button it should be redirected to another page that is this details dot php and inside that file we are going to style this one okay if i you can see we are going to style like this once i click on this i should be having entire data and here i should be having art to cart button in whichever image i click on suppose if i click on this image this particular image i should be getting entire data of that image and i should be getting the price this entire thing so now we are going to design this page now before that when i click on this button i should be redirected to details.php i'll be writing this file i'll just write the proper spelling details dot php i'll come here i'll refresh this one now when i click on this button you can see i'm redirected to details.php now in this file we are going to style that one before that i have to get that particular id because whenever i click on this particular image only that image data should be shown to me and that image data can be accessed using the url id and here i'm just going to give this one i'll just create one question mark and inside this i'm just going to give the file name uh first let me just create one variable i'll just give a details uh details id and here i'm just going to concatenate my category id okay i'll be writing this category id and this is unique for each image i'll just copy this one and here i'm going to paste that category id i'll save this i'll just come here i'll refresh this one now whenever i hover bottom you can see i am getting this details id is equal to 1 details id is equal to 2 id is equal to 3 and when i click on this button you can see details id is equal to 1 again i'll just come back again when i click on this button you can see details id is equal to 2 okay i'll be getting like this and instead of this goes somewhere i'm just going to write here let me just write his shop now i'll save this i'll just come back now you can see here i'll just refresh this one it will be changed through shop now now once i click on this it is redirect to another page now we are going to style this page now inside this details.php first i'm just going to write this basic boilerplate of html i'll just change the title i'll be writing here ecommerce website and below this first i'll be linking bootstrap links i'll just copy this bootstrap link and here inside this details.php i'm just going to paste that one now below this body first i want to connect to database so i have to include these two files include i have to include this connect to connect to my database and this to include the header i'll just copy this to include files and inside this i'm just going to paste that one i'll save this now if i just refresh this one here you can see i'm having this nav bar okay this nav bar is here and i'm successfully connected to my database because i am not having any error here now below this this entire id i have to access okay whatever id i am having here i have to access this id and i have to display only that ids data inside this page now here i'll be writing this php code i'll just write this php syntax and inside this first i have to access that particular id so for that i'm just going to create one variable and using get method we can access the url data now here inside url whatever parameter i'm having here i'll just copy this details hyphen id and here i'm going to paste that one now below this if i just do echo and if i just print and show you id i'll save this now here i'm having id is equal to 1 i'll refresh this you can see i got the output as 1 ok this is how we are going to work suppose i will just come back now again inside this suppose i will just click here 5 id number 5 you can see i'll be getting the output as five okay this is how we are going to fetch the id data and now we are going to display that data now only that particular data i have to access from the database so i'll be writing this query sql first i'll be selecting all the data select star from data okay that is my table name i'll just come here i'll copy this table name my table name is i'll just come here i'm just going to copy this table name clothes and here inside this i am just going to paste that one inside this backticks i am just going to wrap that and here i will be writing one condition where my table category id whatever my table category id i am having inside the table it should be matching with this id okay whatever i have created just now okay this is my table column id and this is my id whatever i have created here suppose here i am getting id is equal to 5 the table which is having id5 only that data will be accessed and that will be shown and only one data i have to access so i should not wrap that inside while loop i will be writing only one time so i will be writing this row and here i will be writing this mysqli fetch as so and inside this i am just going to pass this result variable okay now this result variable is going to execute this query whatever i have written here so here i will be creating result variable inside this i'll be writing this one mysqli query and here i'll be writing this connection connection variable and second it will take query variable sql okay this is how we are going to fetch only one data from the database we are executing the query here and we are fetching this data here now below this inside index.php this entire thing i am just going to copy from here and here i'm just going to paste that one okay i'm just fetching id name description image price of that particular id if suppose i'm having the id number four from the database only that four data only that four id will be selected and everything will be fetched and here i am storing in separate variables now below this let me just write let me just echo this one echo and here i'm just going to write here this entire thing i'll just copy this one and here i'll be pasting that one i'll save this now here i'm having id5 i'll refresh this one in id5 i am having the address name as stylish dress now if i show you inside the database you can see i'm having only stylish dress okay only one data has been felt and that has been displayed to me now here this data i have to display inside jumbotron here i'll just come here i'll just come to bootstrap now from this bootstrap website i'm just going to copy some of the code and we are going to display that data inside that one now here i'll be searching for jumbotron here i'm having this jumbotron i'll just click on this and from here i'm just going to copy this one this first jumbotron i'll just copy this and here below this php syntax i'm just going to paste that one now from here i'm just going to remove some of the content i'll just remove this h1 and in place of h1 i just want to display the heading i'll just write this php i just want to echo this dollar category name i'll just come here i'll just copy this category name and here i'm going to paste that one i'll be closing this php syntax i'll save this i'll come here i'll refresh this one now you can see inside jumbotron i am having this stylish dress now in place of this paragraph let me just remove this paragraph this paragraph i am going to remove and in this place of this paragraph i want to display this description i'll just copy the same thing from here and here i'm going to paste that one and instead of this name i just want to display description i'll save this i'll refresh this one now here i'm having this description you can see entire description has been written now for this button i'm just going to right here continue shopping i'll save this i'll refresh this one now here i'm having this continue shopping now this entire thing i'm just going to wrap inside one container i'll just give the class name as container now inside this i'm just going to wrap this this entire thing i'll save this i'll refresh this one now you can see this now this entire thing has been wrapped inside one container and here for this button i'm just going to give here dark i'll save i'll refresh this one now my button is dark now i'll just remove this continue to shopping and inside my project i'm having only shopping so here let me just write here shopping i'll just come here i'll be writing here shopping i'll save this i'll just come to my project now if i refresh this one here i'm having this heading here i'm having this paragraph and it's loading and my button will be changed to shopping you can see it's been changed to shopping okay let me just see okay i have continued to shopping only let me just give here continue to shopping now here i'll just create one button and inside for this button first i'm just going to give the class name i'll be giving her btn i'll be giving btn dark and inside this button i'm just going to paste this anchor tag i'll just copy this anchor tag from here and here i'm going to paste that one and from here i'll be removing this anchor tag and also this paragraph clo is closing here i'm just going to remove this i'll save this i'll refresh this one now here i'm having this continue shopping button i'll just remove this button large and instead of this href i'll be giving my file name index.php whenever i click on this button i should be moving to index.php file when i click on this button you can see i'm redirected to this page again when i click on this nav bar i'm redirected to index.php now when i click on the shop now here i am having this heading that particular paragraph will be displayed to me okay for this heading i'm just going to give the class name here i'll just write the text center and also i'm just going to give some color i'll just give a text primary okay stylings you don't have to worry you just have to learn the concepts once you learn the concept then you are just going to crack this here i am having this amazing frogs here i am having this paragraph and here i have this continue to shopping now below this i want this image and this entire thing so for that below this diff container i'll just remove this extra spaces now below this diff container i'm just going to create one diff and for this div i'll just give the class name as container inside this diff i'll just create another div and for this div i'll just give the class name as row in my larger screen one image and one text container is visible so it is taking six six space so here i'm just going to give it column as six and i'll be giving here large screen okay in my last screen i want six six and in my smaller screen let me just give here call in my smaller screen devices i'll be giving it to locate only one card and only one text container should be displayed inside this first i'm just going to create image and inside this src i just want to print this one i'll just write this php syntax and inside this i'll be print i'll just echo this category image i'll just come on top i'll just come on top and from here i'm just going to copy this category image variable and here i'm going to paste that one okay i just want to print that one i'll be closing this php syntax and inside this and also i'm just going to give class class is equal to image fluid okay this is bootstrap class you don't have to worry about this now inside now below this i'm just going to create one diff and for this div i'll just give the class name column lg and in my larger screen i want six and in my smaller screen devices i want to will call sm12 now inside this first i'm just going to give h2 and for this i'll just give the text center this is the class name and also i'm just going to give the color color i'll be giving a text danger text danger will give the text in red color now inside this i just want to print the category name so here i'm having this php category name i'll copy this one and here inside this i'm going to paste that one now below this i'm having the paragraph so this entire paragraph i am just going to copy this okay this one i'll just copy this paragraph and here i'm going to paste that one and also i'll be pasting this price i'll just copy the same line and instead of this description i just want to display the price and from here i'm just going to remove this both the classes i'll just remove this and also i'll be removing this and here i'll just write the strong tag and inside this strong i'm just going to write this price here i'll be closing strong now below this paragraph below this paragraph i just want to create one button and for this button i'll be giving the class name as btn i'll just give it btn success btn success will be in green color and inside this button i'm just going to add add to cart i'll save this i'll just refresh once now you can see i'm having this image and here i'm having this amazing frogs heading okay whatever heading i am having here i have this paragraph i have this prize and add to cart button but i want on side by side first i'll just give her price let me just add this one now here this entire diff container i'm just going to copy this i'll cut from here okay this is my first diff okay this is my first div and second div i'm just going to paste here i'll save this i'll refresh this one now you can see i'm having this heading i'm having this paragraph and here i'm having this price okay this is how we are going to style this one i'll just click on continue to shopping now when i click on this image you can see that image i am getting here that particular heading that paragraph that price and that add to cart button again i'll click on continue to shopping i'll click on this wedding dresses you can see that particular image and entire text will be coming okay this is how we are going to get the data using the id number and using that id we are going to fetch the fetch all the data and we are going to display that data you can see and this will be very useful when you are making e-commerce website when you click on particular product that product page will be open and everything about that product should be displayed okay you can add many things here you can just add star ratings you can add reviews okay you can add many things here once you understand the concepts then it will be easy for you to implement this one and you can imagine and you can add many things here okay now we are completed with our php tutorial we are done with our project now there are many advanced topics in php like we have php databases we have to learn php ajax okay we are going to see one by one and this is the complete basic tutorial for beginners if you learn this one then you are ready to go with php and you can create multiple projects learn all these concepts apply these concepts explore more don't stop learning and all the best for whatever you do and thank you so much for listening this have a great day
Info
Channel: Step by Step
Views: 23,870
Rating: undefined out of 5
Keywords: php tutorial, khanam php tutorial, php course, php complete tutorial for beginners, php, php projects, php backend, php ecommerce website, php cart, php complete course, php for beginners, php crash course, khanam php, php tutorial khanam, beginners php guide, php crud, php course by khanam, php course from scratch, complete crash course on php, backend programming for beginners, complete ecommerce website for beginners, php crud operation, php cart projects, php and mysql
Id: wy-eTUf4ang
Channel Id: undefined
Length: 263min 23sec (15803 seconds)
Published: Wed Sep 22 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.