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 number of flags can be added to change the way that this function works. Here are the flags available. FILTER_FLAG_SCHEME_REQUIRED Require … 'http://www.hashbangcode.com' => array(), 'http://www.hashbangcode.com/blog' => array(), 'http://www.example.com/index.html#anchor' => … => array(), 'www.example.com' => array(), 'www.example.com/blog' => array(), 'www.example.com/index.html?q=123' => array(), …
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 …
Article: PHP Function To Get TinyURL
… where you can convert a long URL string to a really small one. For instance, the following URL, which points to the Googleplex on … Can be converted to the following. http://tinyurl.com/qpkor2 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 …
… to the function. The following example reads a web page using the PHP CURL functions and then passes the result into the function to retrieve the links. $url = 'http://www.hashbangcode.com'; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$url); …
Article: Shortening Long URLs With PHP
… Print out a full URL for a link will sometimes mess up your formatting, especially if you URL is quite long. This might be the case if you are linking to a Google search page, or have an automated script that shows numerous URLs of indeterminate length. The following function will reduce any …