Category : "PHP"

Php tutorials

Websockets with php – tutorial on basics

Websockets Websockets is a new feature available in browsers as a part of the Html5 specs that allows javascript clients to open bi directional socket connections to a server. Currently all major desktop browsers support the api. Websocket is not an independant socket protocol, but is based on the TCP protocol just like HTTP. Therefore websocket connections are basically tcp socket connections ...

Generate a dropdown list of timezones in php

Applications often allow users to select their timezones for reporting the proper time properly. Here is a quick function that can be used to generate a dropdown list of timezones that is easy to read and understand. <?php function get_timezones() { $o = array(); $t_zones = timezone_identifiers_list(); foreach($t_zones as $a) { $t = ''; try { //this throws exception for 'US/Pacific-New' $zone = new DateTimeZone($a); $seconds = $zone->getOffset( new DateTime("now" , $zone) ); $hours ...

Php array of iso 639-1 language codes and names

Here is a php array containing the language codes and language names as specified by the iso 639-1 standard. Useful when . <?php /** ISO 639-1 Language Codes Useful in Locale analysis References : 1. http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes 2. http://blog.xoundboy.com/?p=235 */ $language_codes = array( 'en' => 'English' , 'aa' => 'Afar' , 'ab' => 'Abkhazian' , 'af' => 'Afrikaans' , 'am' => 'Amharic' , 'ar' => 'Arabic' , 'as' => 'Assamese' , ...

Php function to get the last day of a month

Here is a function that would get the last day of a given month as a date in format Y-m-d. It first adds 1 month to the 1st date of the given month, then subtracts 1 second from the resulting date which brings back to the last date of the given month. /** Last date of a month of a year @param $month ...

Convert pdf to image with imagemagick in php

Imagick In a previous article we saw how to use to create a snapshot or thumbnail of the pdf. Now we are going to do the same in php using the Imagick class which provides the bindings for imagemagick library inside php. The library is available in the form of a class Imagick that does all the job of imagemagick ...

Php curl tutorial – making http requests in php

Curl According to the official website. curl is a command line tool for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. curl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cookies, user+password authentication (Basic, Digest, NTLM, ...

Generate code39/isbn barcodes in php with mpdf

Barcodes Barcodes are used in various business class applications to print information in encoded format such that it can be read later by barcode reading devices. Common places to see barcodes are product covers in shops, membership cards and documents like invoices etc. As php is now increasingly being used to develop such applications, barcodes need to be printed from php. There ...

6 tips to learn PHP fast and effectively

Php is today the most widely used language/platform for development of web based applications and websites. At the same time it is the easiest to learn and use. There are lots of free tutorial websites out there that can be followed to learn php without much effort. Along with these tools having the right approach can speed up the learning ...

Send html emails in php using the mail function

The mail function of php can be used to send not only plain text emails, but html emails too. The documentation page shows how to do that. Here is a easy to use function that does the task and has a form very similar to the mail function. function html_mail($to, $subject, $message, $options) { if(isset($options)) { $headers = "From: " . $options . "<".$options.">" . "rn"; } $headers ...

Fill text templates using arrays in php

Text templates are often used to generate content like notification emails, invoices filled with the details of a customer or user. The best example would be a bulk email program that sends out emails to multiple users filling the details of the particular user in every individual mail. Text templates have place holders for fields which can be filled using an ...



Connect with us