Search Results
… I'm always searching for this information when I need to print out a URL or find the current page path. The difficulty is that finding or printing out a URL is very contextual and there is more than one way to get or use … there is very little documentation on drupal.org about this. Creating URLs and printing out links is perhaps the most common thing that needs …
Article: Some Useful Curl Snippets
… Curl is an incredibly useful tool and has all sorts of flags and options available for every situation. I tend to use curl quite a lot for all kinds of stuff, and not just downloading large … common things that I use the tool for. Note that most of the following URLs don't really exist, they are just for demo purposes. I have also …
… a while ago I looked at using the filter_var() function to validate URL's using the FILTER_VALIDATE_URL flag and someone pointed out recently that this function has not … Require the scheme (eg, http://, ftp:// etc) within the URL. FILTER_FLAG_HOST_REQUIRED Require host of the URL (eg, …
Article: Tidy Up A URL With PHP
… Lots of applications require a user to input a URL and lots of problems occur as a result. I was recently looking for something that would take a URL as an input and allow me to make sure that is was formatted … so I decided to write it myself. The following function takes in a URL as a string and tries to clean it up. It essentially does this by …
… Netscape HTTP cookie file. This file is generated by PHP when it runs CURL (with the appropriate options enabled) and can be used in subsequent CURL calls. This file can be read to see what cookies where created after CURL has finished running. As an example, this is the sort of file that …
… // Initialise curl. $ch = curl_init(); $url = 'https://www.hashbangcode.com/'; // Setup curl to fetch the headers. curl_setopt($ch, CURLOPT_URL, $url); …
Snippet: Reverse parse_url() PHP Function
… This function does the opposite process of the parse_url() function in PHP. It converts the full array of components back into a URL string. /** * Generate URL from its components. * * This is essentially the opposite of …
Article: PHP Function To Get TinyURL
… a service where you can convert a long URL string to a really small one. For instance, the following URL, which points to the Googleplex on … This is perfect for posting to Twitter or similar microblogging platforms as it saves lots of character space. Luckily, …
Article: Downloading Alexa Data With PHP
… associated keywords and Dmoz listings. As an example here is a feed URL for getting information about the bbc.co.uk page. … i=10&dat=nsa&ver=quirk-searchstatus&uid=19700101000000&userip=127.0.0.1&url=www.bbc.co.uk So to get information about any site all you have to do is pass the correct URL to this address. To get this information in a usable form with PHP …
… research for those articles. It appears that the filter to validate URL string, namely FILTER_VALIDATE_URL, is not really adequate to the task. Take the following examples of the filter in an if statement. if ( filter_var($url,FILTER_VALIDATE_URL) ) { return true; }else{ return false; }; This …