Was experimenting with the HTML <select> multiple Attribute today.
Author Archives: Jay Jay
PHP str_pad
Found myself using the PHP function str_pad today to format a hex string as a six digit HTML/CSS colour code.
e.g.:
$code = str_pad( dechex( $rgb ), 6, '0', STR_PAD_LEFT );
The str_pad function is implemented in JavaScript at jsphp.co.
HTML/CSS hexadecimal colour codes
Found a few handy web pages that help pick HTML/CSS colours. Hex Hub and Hexadecimal Color Codes.
Making a HTML element’s width equal to its contents
Today I learned how to make a HTML element’s width equal to its contents.
Basically you use CSS and set the element’s “display” property to “inline-block”.
PHP ini file allow_url_include configuration option
Today I enabled the allow_url_include configuration option in PHP on Apache on ProgClub MemberNet. This allows me to include a source file directly from svn, e.g.:
require_once( 'https://www.progclub.org/svn/pcrepo/slib/trunk/src/uri.php' );
Themeing my MemberNet web-page
Finally got around to making my MemberNet web-page look nice and pretty. Also integrated the look and feel with all of my PHP tests.
PHP get_called_class function
I learned about the PHP get_called_class function today. Basically it returns the name of the class that the function that’s running is defined in. Handy for figuring out which class a static method is running in. Compare with get_class.
Reading a file in PHP
The file function parses a text file into an array, and the file_get_contents function returns a text file as a string.
PHP ini file user_agent configuration option
Today I discovered the user_agent php.ini configuration option. Basically it allows you to specify the user agent PHP uses when it sends HTTP requests for files. I was screen scraping some data from Wikipedia (processing URI schemes) and it was replying with a 403 error, presumably because they’ve banned the default PHP user agent. Anyway I just changed my user agent to a copy of my one from Firefox and things started working. Pretty handy option!
CSS overflow Property
I used the CSS overflow Property today and set it to ‘auto’ so that my code fit on the screen.
pre { overflow: auto; }