Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 14, 2019 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/84cd3ba74a50b3f8960628dc1e3d2e23 to your computer and use it in GitHub Desktop.
Save parzibyte/84cd3ba74a50b3f8960628dc1e3d2e23 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
# Tomada de https://stackoverflow.com/questions/1734250/what-is-the-equivalent-of-javascripts-encodeuricomponent-in-php
function encodeURIComponent($str) {
$revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
return strtr(rawurlencode($str), $revert);
}
$mensaje = "Creando enlaces de WhatsApp desde PHP. https://parzibyte.me/blog";
$enlace = "https://api.whatsapp.com/send?text=" . encodeURIComponent($mensaje);
?>
<a href="<?php echo $enlace ?>">Compartir</a>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment