test php curl - PHP Online
Form of PHP Sandbox
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of test php curl.php
- <?php
- // example code
- function transformUrl($url) {
- // Ensure scheme is present and lowercase
- $url = strtolower($url);
- // Check if the URL starts with "http://" and convert to "https://"
- if (preg_match("~^http://~", $url)) {
- $url = preg_replace("~^http://~", "https://", $url);
- } elseif (!preg_match("~^https://~", $url)) {
- // If the URL doesn't start with "https://", prepend "https://"
- $url = "https://" . $url;
- }
- // Parse the URL and decode percent-encoded values
- $parsedUrl = parse_url($url);
- $path = isset($parsedUrl['path']) ? urldecode($parsedUrl['path']) : '';
- // Construct the transformed URL without query parameters
- $host = $parsedUrl['host'];
- $transformedUrl = $parsedUrl['scheme'] . '://' . $host . $path;
- return $transformedUrl;
- }
- echo transformUrl('http://www.homepro.co.th/c/app160301?.a=222');
- echo "<br>";
- echo transformUrl('http://www.homepro.co.th/c/app160301?a=222&b=2333');
- echo "<br>";
- echo transformUrl('http://www.homepro.co.th/c/app160301');
- echo "<br>";
- echo transformUrl('http://homepro.co.th/c/app160301?a=222');
- echo "<br>";
- echo transformUrl('http://homepro.co.th/c/app160301?a=222&b=2333');
- echo "<br>";
- echo transformUrl('http://homepro.co.th/c/app160301');
- echo "<br>";
- echo transformUrl('homepro.co.th/c/app160301?a=222');
- echo "<br>";
- echo transformUrl('homepro.co.th/c/app160301?a=222&b=2333');
- echo "<br>";
- echo transformUrl('homepro.co.th/c/app160301');
- echo "<br>";
- echo transformUrl('www.homepro.co.th/c/app160301?a=222');
- echo "<br>";
- echo transformUrl('www.homepro.co.th/c/app160301?a=222&b=2333');
- echo "<br>";
- echo transformUrl('www.homepro.co.th/c/app160301');
- echo "<br>";
- echo transformUrl('http://www.Homepro.co.th/c/app160301?a=222');
- echo "<br>";
- echo transformUrl('http://www.hOmepro.co.th/c/app160301?a=222&b=2333');
- echo "<br>";
- echo transformUrl('http://www.homepro.co.th/c/app160301');
- echo "<br>";
- echo transformUrl('https://www.homepro.co.th/c/app160301?.a=222');
- echo "<br>";
- echo transformUrl('https://www.homepro.co.th/c/app160301?a=222&b=2333');
- echo "<br>";
- echo transformUrl('https://www.homepro.co.th/c/app160301');
- echo "<br>";
- echo transformUrl('https://homepro.co.th/c/app160301?a=222');
- echo "<br>";
- echo transformUrl('https://homepro.co.th/c/app160301?a=222&b=2333');
- echo "<br>";
- echo transformUrl('https://homepro.co.th/c/app160301');
File Description
- test php curl
- PHP Code
- 10 Apr-2024
- 2.35 Kb
You can Share it:
Latest PHP Pastes