Tag

HTML

Browsing

Today, We are going to learn PHP remove HTML tags from a string. We can remove HTML tags from the string using two ways. First, PHP provides the strip_tags function for removing HTML tags and preg_replace function for removing HTML tags from a string, Today, We learn both functions with the example.

  • Remove HTML tags using strip_tags function
  • Remove HTML tags using preg_replace function

PHP remove HTML tags from a string

We are going to learn the first example using strip_tags function.

Remove HTML tags using strip_tags function

We are using the strip_tags function for removing the HTML tags from the string. So, it’s very easy to remove HTML tags from a string. But the “strip_tags” add space after removing the tags from the string like.

The output of the above statement is “Hello world!” instead of “Helloworld!”.

So, let’s see the second example for removing HTML tags from a string and get the output like “Helloworld!” instead of “Hello world!”.

Remove HTML tags using preg_replace function

The output of the above function is “Helloworld!” instead of “Hello world!”.

We check the both function with the example Now, choose the which function is helpful for you and use it for removing HTML tags from a string.

If you face any issue after using above code 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.