note 128838 added to function.urlencode

From: Date: Tue, 29 Aug 2023 00:31:03 +0000
Subject: note 128838 added to function.urlencode
Groups: php.notes 
Request: Send a blank email to php-notes+get-220800@lists.php.net to get a copy of this message
this function will encode the URL while preserving the functionality of URL so you can copy and paste it in the browser ``` function urlEncode($url) { $parsedUrl = parse_url($url); $encodedScheme = urlencode($parsedUrl['scheme']); $encodedHost = urlencode($parsedUrl['host']); $encodedPath = implode('/', array_map('urlencode', explode('/', $parsedUrl['path']))); if (isset($parsedUrl['query'])) { $encodedQuery = '?' . urlencode($parsedUrl['query']); } else { $encodedQuery = ''; } return "{$encodedScheme}://{$encodedHost}{$encodedPath}{$encodedQuery}"; } ``` ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 2.104.7.184) ---- Manual Page -- https://php.net/manual/en/function.urlencode.php Edit -- https://main.php.net/note/edit/128838 Del: integrated -- https://main.php.net/note/delete/128838/integrated Del: useless -- https://main.php.net/note/delete/128838/useless Del: bad code -- https://main.php.net/note/delete/128838/bad+code Del: spam -- https://main.php.net/note/delete/128838/spam Del: non-english -- https://main.php.net/note/delete/128838/non-english Del: in docs -- https://main.php.net/note/delete/128838/in+docs Del: other reasons-- https://main.php.net/note/delete/128838 Reject -- https://main.php.net/note/reject/128838 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220800) next »