Tag

PHP

Browsing

Today, We are going to learn How to create Category tree from Array using PHP. Many times we need to create the parent and child category tree. Let’s make it easy with a single function. Yes, You can create the parent and child tree from Array using a single PHP function. Let’s follow the function and pass Array for creating parent and child category tree.

Category tree from Array

Finally, Our function is ready Now, you just need to pass the category array-like.

Now, let’s pass this Array to buildTree then check the output.

We got output something like below.

So, Our category tree is ready with parent and child hierarchy.

If you face any issue after using this code please write a comment.

Nowadays, PHP is a highly used language for Web development. So, Today we are going to learn file upload functionality. PHP file upload functionality is very easy and almost every application has file upload functionality. So, We must have knowledge about How to upload file on PHP. So, let see how to upload a file using PHP programming. You must have some basic knowledge of HTML for creating form.

PHP File upload

First of all, We are going to create the HTML form. So, let’s create the fileupload.html HTML file. Then write the following code.

We are ready with the HTML form. Now, let’s create the PHP code for handling the uploaded file and store it into the directory. First of all, create the fileupload.php PHP file. Then write the following PHP code.

Finally, We are ready with the PHP file upload code. Before, running PHP file upload example please create the uploads directory at the root directory of your project. Then after selecting a file and upload it and check the file is stored on uploads directory.

If you face any issue after following the code please write the comment below. We are always ready for help.

In the last example, We learn about single line comment. In this example, We are going to learn PHP multi-line comments. In multi-line comment PHP allow us to write multiple lines as a comment. Every developer must write the comment. So, another developer easily understands the code.

PHP multi-line comments

First of all, We are going to create a new PHP file for multi-line comment example. So, Let’s create a new file at “C:\xampp\htdocs\first\thecodignstuff.php” then write the below code.

Finally, We are ready with a multi-line comment example. So, Let’s run the file and check the output like

Hello World!20

The comments are not visible on output it’s only usable for a developer. If you face any issue on this example write the comment below.

PHP stands for Personal Home Page. PHP also was known as Hypertext processor language. Today, We are going to learn PHP Single Line comment example. Every language provides comment system. A developer must have habits to write down comment before writing the code. So, when another developer starts working or trying to read code his easily understand.

PHP Single Line comment

Every developer must have habits to write the comment. Let’s see, How we can write the single line comment on PHP. So, First of all, We are going to create a PHP file at “C:\xampp\htdocs\first\comment.php” then write the code like

When we run our example our output something looks like this.

Hello World!20

The Comments are not visible to the user. it’s only for developer use. If you face any issue on this example please write the comment below.

PHP stands for Personal Home Page. PHP also was known as Hypertext processor language. HTML stands for Hypertext Markup Language. Today, We are going to learn how we can embedding PHP in HTML. Actually, We are going to embedding HTML in PHP file. HTML is client side language and PHP is server-side language. PHP manage backend login and passing data to HTML. HTML handle that data and display to a user. Today, We are going to embedding “Hello World!” example with HTML.

Embedding PHP in HTML

We are going to embedding HTML in PHP. So, First of all, We should create a PHP file for our example. Let’s create the file at “C:\xampp\htdocs\first\thecodingstuff.php” then write the code like.

So, it’s too easy We can easily embedding HTML in PHP file like above example. Now, let’s run our example by following “http://localhost/first/thecodingstuff.php” URL. If you face any issue in this example write the comment below.

PHP stands for Personal Home Page. PHP is also known as Hypertext processor language. Today, We are going to start with our first PHP Program PHP Hello World. In any programming language, We start by writing out first ‘Hello World’ program in PHP.  So, Let’s we are going to starting with our first PHP program PHP Hello World.

PHP Hello World

First of all, We should create the PHP file for the Hello World program. So, let’s create the PHP file at “C:\xampp\htdocs\first\helloworld.php” then write the code like.

Now, let’s run that PHP file and check the output. Let’s open “http://localhost/first/helloworld.php” URL on your browser. The PHP program output something look like.

Hello World!

So, First PHP program output is print on the browser “Hello World!”. I hope this example is working for you. If you face any issue related this example please write the comment.