Home > Backend Development > PHP Problem > How to use %3c in PHP? Three use cases shared

How to use %3c in PHP? Three use cases shared

PHPz
Release: 2023-03-22 17:16:02
Original
2003 people have browsed it

PHP is a server-side scripting language that is the basis of many websites. There are many different tips and techniques you can use when writing websites using PHP, including special uses of <. in this article we will explore usage and the benefits of using them php.>

First, let’s take a look at what

For example, if you wanted to use a left angle bracket inside a title tag, you could code like this:

<h1>%3cHello World%3c/h1>
Copy after login

This would create a title with the text "" .

  1. Use <

in URLs When writing URLs in PHP, if you need to include a left angle bracket in the URL, then you It must be escaped as <. This is one of the most common ways to use < in a URL.

For example, if you want to add the user's username to the URL, you can use the following code:

$username = &#39;JohnDoe&#39;;
$url = &#39;http://www.example.com/profile.php?username=%3c&#39;.$username.&#39;%3c&#39;;
Copy after login

In this example, $url will contain a username, which will Insert into the URL.

  1. Using <

inside JavaScript When writing JavaScript code, you may need to include HTML tags in your strings. For example, if you want to write a string into an HTML document and style it to be bold, you can use the following code:

var message = &#39;This message will be displayed in bold&#39;;
document.getElementById(&#39;message&#39;).innerHTML = message;
Copy after login

In this example, we can use < to enclose the left angle bracket Encoded as URL. The code is as follows:

var message = &#39;This message will be displayed %3cin bold%3c&#39;;
document.getElementById(&#39;message&#39;).innerHTML = message;
Copy after login

This will create an HTML element with bold text, which contains a left angle bracket.

Summary

Using special uses of

The above is the detailed content of How to use %3c in PHP? Three use cases shared. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template