Categories

Thousands of experts bid on your personal project at ScriptLance.com

Tinyurl and PHP

This example utilises tinyurl to create a short url

 

<?php /* gets a short url from tinyurl service */ function tinyurl($url)  {      $ch = curl_init();      $timeout = 5;      curl_setopt($ch,CURLOPT_URL,’http://tinyurl.com/api-create.php?url=’.$url);      curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);      curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);      $data = curl_exec($ch);      curl_close($ch);      //return the [...]

Random string

generates a random string from an array of characters

<?php // function to generate random strings function RandomString($length=32) { $randstr=”; srand((double)microtime()*1000000); //our array add all letters and numbers if you wish $chars = array ( ‘a’,’b’,’c’,’d’,’e’,’f’); for ($rand = 0; $rand <= $length; $rand++) { $random = rand(0, count($chars) -1); $randstr .= $chars[$random]; } return $randstr; [...]

PHP and cURL example

<?php//the site or URL to get$ch = curl_init(""http://www.google.com/"");//set the options for the transfercurl_setopt($ch, CURLOPT_HEADER, 0);//execute the sessioncurl_exec($ch);//free up system resources !!IMPORTANTcurl_close($ch);?>

Bookmark It

Hide Sites

$$(‘div.d99′).each( function(e) { e.visualEffect(’slide_up’,{duration:0.5}) });

read contents of a directory

reads in the contents of a directory and display as links

<?function directory($result) {

$handle=opendir("".""); while ($file = readdir($handle)) { if ($file == ""."" || $file == "".."") { } else { print ""<a href=$file>$file</a><br>""; }

} closedir($handle); return $result; } echo directory($result); ?>

Bookmark It

Hide Sites

$$(‘div.d98′).each( function(e) { e.visualEffect(’slide_up’,{duration:0.5}) });

Read an ini file

The contents of the ini file are listed below

[settings1] text1 = "hello" text2 = "world"

[settings2] number1 = 4 number2 = 8

//print out all of the contents of the test.ini file

<?php $ini_array = parse_ini_file("test.ini");print_r($ini_array);?>

Bookmark It

Hide Sites

$$(‘div.d97′).each( function(e) { e.visualEffect(’slide_up’,{duration:0.5}) });