Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP using &lt; and &gt; in place of < and > [closed]

Tags:

php

I'm following an online PHP tutorial which uses &lt; and &gt; instead of < and > in the PHP code. For example:

&lt;?php

class User {
function __construct($data) {
    $this-&gt;id = (isset($data['id'])) ? $data['id'] : "";
    $this-&gt;username = (isset($data['username'])) ? $data['username'] : "";
    $this-&gt;hashedPassword = (isset($data['password'])) ? $data['password'] : "";
    $this-&gt;email = (isset($data['email'])) ? $data['email'] : "";
    $this-&gt;joinDate = (isset($data['join_date'])) ? $data['join_date'] : "";
}

Is there a reason this is being done or is the formatting on the tutorial website causing it to display like that?

i.e. should I actually be using &lt; and &gt; in my .php files?

like image 466
Collin Avatar asked Mar 22 '23 02:03

Collin


1 Answers

The tutorial you are following is broken. They are using something to format code in the tutorial, and it is double-escaping the code. You don't need to worry about that.

&lt; and &gt; are entities that are used in HTML and XML documents. They are not needed in your PHP code. If you output HTML with your PHP code, then the HTML part you output should contain them if you wish your document to contain a < or >.

like image 142
Brad Avatar answered Apr 06 '23 12:04

Brad