Search Results
… 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 …
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 …
… 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 …
Article: Capture A Website As Image With PHP
… the Thumbshots website. <img src="http://open.thumbshots.org/image.pxf?url=http%3A%2F%2Fwww.hashbangcode.com%2F" alt="Site image" /> Websnapr … for a small image of #! code. <img src="http://images.websnapr.com/?url=http%3A%2F%2Fwww.hashbangcode.com%2F&size=s" alt="Site image" /> … in pixels. sdy : The height of the rendering browser in pixels. url : The URL that the image is to be created from. So putting these …
Article: Preparing A URL With PHP
… be many instances where you will create a program in PHP that takes a URL as input and does something with the address. This might be a site … an image resize, but whatever the use is, you need to be sure that the URL will work or at least has the same format. What users tend to leave out of a URL string is the http:// bit at the start. You could validate the URL …