phpdoc-msg
These pages have been retired, check out php docs
Link to this post!
These pages have been retired, check out php docs
Link to this post!
Problem
You want to ping a host on a given port and record time taken in microseconds.The following solution uses PHP socket libraries to open a connection, to the given host and port – then just close it again. By obtaining the microseconds before and after, it is able to deduce time taken in microseconds.Additionally [...]
Problem
You have a requirement to capture network speed, in microseconds.The required speed was less than 0.25 of a second (or quarter of second).
Solution
We use PHP to capture the current time in microseconds. Run a system ping command. Capture the new time and minus one from the other.
Example
Here's the PHP code, using the microtime [...]
Problem
you want to run queries against a Sybase Database, using the PHP API.
Solution
A PHP script using sybase API for PHP, connect as given user, with your password on specific host.
Example
Useful for monitoring sybase dbs, although in this instance it does not actually hit any database tables.<?php$user = “your_user”;$passwd = “password”;$host = “your_host”;$sql=”select getdate(), @@version “;$conn=sybase_connect($host,$user,$pass); [...]
Problem
You want to generate an image, with text over the top.
Solution
Why of course we use PHP extensive image library routines!
Example
<?phpheader(“Content-type: image/png”);$string = $_GET[‘label’];if(isset($_GET[‘font’])) { $font = $_GET[‘font’]; } else { $font=“2″; }$len=strlen($string);$text_width = imagefontwidth($font);$text_height = imagefontwidth($font);/* Create a blank image */$im = imagecreate (($len*$text_width)+10, $text_height+10);$bgc = imagecolorallocate ($im, 0, 0, 0);$tc = imagecolorallocate [...]
Problem
You want to transform text form ascii to base64, urlencode it, digest it, etc.Or you want to decode these formats.
Solution
Just wrote this tool, to allow instant transformation of data into following formats:base64 encode decode, urlencode decode, md5 and sha1 hashing, addslashes and htmlentitiesclick here to access the transform toolPretty cool to see ‘all’ too – [...]
Problem
You need to make a thumbnail of an image, on the fly.
Solution
Here is a short PHP script to make a thumbnail out of the image.It takes two arguments, one for the image’s file name and one for the compression rate.
Example
displayThumb.php<?php$filename = $_GET['filename'];$compression = $_GET['compression'];Header(”Content-type: image/png”); $im = imagecreatefrompng(”$filename”); [...]
Problem
You need to convert a GIF into a PNG.
Solution
Another short bit of PHP, which takes a GIF filename as a parameter and a compression tag,so you can convert to PNG and change size too.If you don’t want to compress the image, just use a value of 100.
Example
convertGifPng.php<?php$filename = $argv[1];$compression = $argv[2];Header(”Content-type: image/png”); [...]
Problem
Having written a ga-zillian scripts, to query dbs, decided it would be much simpler to call just one function multiple times, duh! Then fulfilling business request after request – with many short php web pages calling the function. Decided to progressing this further – by removing the web page altogether (hitting the function [...]
Problem
You want to create a wordpress plugin, which substitutes your tags for HTML.
Solution
This was a million times easier than I thought it was going to be. step 1: mkdir wordpress/wp-content/plugins/YourPluginNamestep 2: vi wordpress/wp-content/plugins/YourPluginName/Your Plugin Name.phpstep 3: activate your plugin
Example
Here I want to substitute the following tags, with content wrapping.[problem] … [...]
Search engine optimization by SEO Design Solutions