Skip to content

Instantly share code, notes, and snippets.

View cp-sumi-k's full-sized avatar

Sumita Kevat cp-sumi-k

View GitHub Profile
<?php
$str = 'V2UgZG8gd2hhdCBtYXR0ZXJzIHRoZSBtb3N0ISE=';
echo base64_decode($str);
# output : We do what matters the most!!
?>
<?php
$str = 'We do what matters the most!!';
echo base64_encode($str);
# output : V2UgZG8gd2hhdCBtYXR0ZXJzIHRoZSBtb3N0ISE=
?>
<?php
$str = '?5V4@;6]V92!F87-T(&%N9"!B<F5A:R!T:&EN9W,A(0``';
error_log(convert_uudecode($str));
# output : We move fast and break things!!
?>
<?php
$str = 'We move fast and break things!!';
error_log(convert_uuencode($str));
# output : ?5V4@;6]V92!F87-T(&%N9"!B<F5A:R!T:&EN9W,A(0``
?>
<?php
echo urlencode("https%3A%2F%2Fcanopas.com%3Fdata%3Dtest");
# output : https://canopas.com?data=test
?>
<?php
echo urlencode("https://canopas.com?data=test");
# output : https%3A%2F%2Fcanopas.com%3Fdata%3Dtest
?>
<?php
$str = "&lt;a href=&#039;https://canopas.com&#039;&gt;Let&#039;s explore&lt;/a&gt;";
echo html_entity_decode($str); // in browser
error_log(html_entity_decode($str)); // in console
/*
output
In browser : Let's explore
In console : <a href='https://canopas.com'>Let's explore</a>
<?php
$str = "<a href='https://canopas.com'>Let's explore</a>";
echo htmlentities($str); // in browser
error_log(htmlentities($str)); // in console
/*
output
In browser : <a href='https://canopas.com'>Let's explore</a>
In console : &lt;a href=&#039;https://canopas.com&#039;&gt;Let&#039;s explore&lt;/a&gt;
myFunc("John");
function myFunc(name) {
console.log("My name is " + name); //My name is John
}
function sum(...args) {
let sum = 0;
for (let arg of args) {
sum += arg;
}
return sum;
}
// can pass any number of arguments