PHP code example of laravelgems / escape

1. Go to this page and download the library: Download laravelgems/escape library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laravelgems / escape example snippets


<div>
    <label><?= \LaravelGems\HTML::text($label) 

<a href="#" onclick="UNTRUSTED DATA HERE">My Link</a>
<a href="UNTRUSTED DATA HERE">My Link</a>

<div><?= \LaravelGems\HTML::text($untrustedData) 

<input type="text" name="username" value="<?= \LaravelGems\HTML::attr($untrustedData) 

<span style="property: '<?= \LaravelGems\HTML::css($untrustedData) 

<script>var username="<?= \LaravelGems\HTML::js($untrustedData) 

<a href="/profile?username=<?= \LaravelGems\HTML::param($untrustedData) 

<!-- Unsafe html attributes - there no way to protect you in 100% cases without validation first -->
<embed src="<?= htmlentities("javascript:alert(1)") 

<!-- WRONG WAY: htmlentities() is not enough in JS context -->
<script>var a = "<?= htmlentities($untrustedData)