Welcome to the David Walsh Blog! This website was created to reach every audience possible. Please contact me at david@davidwalsh.name to let me know if I can do anything to further improve your experience on this website.

PHP Archives

Read PDF and Word DOC Files Using PHP

Debuted Friday, January 2, 2009 @ 9:12 am
Sugar: PHP · Shell · link()

One of my customers has an insane amount of PDF and Microsoft Word DOC files on their website. It’s core to their online services so it’s not as though they’re garbage files up on the server. My customer wanted their website’s search engine (Sphider) to read these PDF files and DOC files so that their clients could get at the documents they needed without going through a bunch of summary pages to get them. I was successful in the task, so let me show you how to read PDF and DOC files using PHP.

Article Sep

Create an Is.Gd URL Using PHP

Debuted Monday, December 29, 2008 @ 8:58 am
Sugar: PHP

Is.Gd is a URL-shortening service much like TinyURL. Using PHP’s cURL library, you can create shortened URLs on the fly with ease.

The PHP

//gets the data from a URL  
function get_isgd_url($url)  
{  
	//get content
	$ch = curl_init();  
	$timeout = 5;  
	curl_setopt($ch,CURLOPT_URL,'http://is.gd/api.php?longurl='.$url);  
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);  
	curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);  
	$content = curl_exec($ch);  
	curl_close($ch);
	
	//return the data
	return $content;  
}

//uage
$new_url = get_isgd_url('http://davidwalsh.name/php-imdb-information-grabber');

“is.gd” is much shorter than “tinyurl.com” so if you need the URL to be as short as possible, use this method.

Article Sep

Create Tiny URLs with TinyURL, MooTools, and PHP

Debuted Wednesday, December 24, 2008 @ 8:58 am
Sugar: .htaccess · AJAX · Blog · MooTools · PHP · XML / XHTML · link()

Since we’ve already figured out how to create TinyURL URLs remotely using PHP, we may as well create a small Ajax-enabled tiny URL creator. Using MooTools to do so is almost too easy.

The XHTML (Form)

<p><strong>URL:</strong> <input type="text" id="url" size="40" /> <input type="button" id="geturl" value="Get URL" /></p>
<p id="newurl"></p>

We need an input box where the user will enter their a URL, a button to trigger the process, and a placeholder to put the new, tiny URL.





 

 

comments twitter