-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from nguyenanhung/develop
Add some helper in url_helper
- Loading branch information
Showing
5 changed files
with
61 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,4 +123,4 @@ function __get_error_trace__($e) | |
{ | ||
return "Error Trace: " . $e->getTraceAsString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -461,3 +461,59 @@ function audio_url($input = '') | |
return $audio_url; | ||
} | ||
} | ||
if (!function_exists('append_params_into_url')) { | ||
/** | ||
* Function Append parameters to URL | ||
* | ||
* @param $url | ||
* @param $params | ||
* | ||
* @return string | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 17/04/2023 29:59 | ||
*/ | ||
function append_params_into_url($url, $params) | ||
{ | ||
$urlParts = parse_url($url); | ||
if (isset($urlParts['query'])) { | ||
$queryParams = []; | ||
parse_str($urlParts['query'], $queryParams); | ||
$queryParams = array_merge($queryParams, $params); | ||
$urlParts['query'] = http_build_query($queryParams); | ||
} else { | ||
$urlParts['query'] = http_build_query($params); | ||
} | ||
|
||
$newUrl = $urlParts['scheme'] . '://' . $urlParts['host'] . $urlParts['path'] . '?' . $urlParts['query']; | ||
|
||
if (isset($urlParts['port'])) { | ||
$newUrl = $urlParts['scheme'] . '://' . $urlParts['host'] . ':' . $urlParts['port'] . $urlParts['path'] . '?' . $urlParts['query']; | ||
} | ||
|
||
return $newUrl; | ||
} | ||
} | ||
if (!function_exists('append_query_string_to_current_url')) { | ||
/** | ||
* Function Get current URL including query string | ||
* | ||
* @return string | ||
* @author : 713uk13m <[email protected]> | ||
* @copyright: 713uk13m <[email protected]> | ||
* @time : 17/04/2023 31:27 | ||
*/ | ||
function append_query_string_to_current_url() | ||
{ | ||
if (function_exists('current_url')) { | ||
$url = current_url(); | ||
if (!empty($_SERVER['QUERY_STRING'])) { | ||
$url .= '?' . $_SERVER['QUERY_STRING']; | ||
} | ||
|
||
return $url; | ||
} | ||
|
||
return ''; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters