<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-29695035</id><updated>2011-12-14T19:03:01.586-08:00</updated><title type='text'>Ruby on Rails, PHP, Web2.0</title><subtitle type='html'>Step down at my blog with your ideas,comments,suggestions on Ruby on Rails, PHP or Web2.0 Technology.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-29695035.post-115631999592693259</id><published>2006-08-23T00:40:00.000-07:00</published><updated>2006-08-23T00:59:56.626-07:00</updated><title type='text'>refresh a page in PHP</title><content type='html'>########## mymeta.php ##############&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;&amp;lt;meta HTTP-EQUIV="refresh" content=5;url="bye.html"&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;h1&amp;gt;hello&amp;lt;/h1&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;############### bye.html ############&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;h2&amp;gt;BYE&amp;lt;/h2&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;br /&gt;meta HTTP-EQUIV="refresh" is going to take same action on the browser as an HTTP header takes.&lt;br /&gt;content =5 i.e 5 seconds&lt;br /&gt;url: the page u want after 5 seconds.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115631999592693259?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115631999592693259/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115631999592693259' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115631999592693259'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115631999592693259'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/08/refresh-page-in-php.html' title='refresh a page in PHP'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115625492857855213</id><published>2006-08-22T06:46:00.000-07:00</published><updated>2006-08-22T06:55:28.640-07:00</updated><title type='text'>Create Database/Table With PHP</title><content type='html'>&lt;div class="codebox"&gt;    &lt;p&gt;&lt;?php&lt;br /&gt;   include 'config.php';&lt;br /&gt;   include 'opendb.php';&lt;/p&gt;   &lt;p&gt;&lt;strong&gt;$query  = "CREATE DATABASE rajdb";&lt;br /&gt;   $result = mysql_query($query);&lt;/strong&gt;&lt;br /&gt;  &lt;br /&gt;   include 'closedb.php';&lt;br /&gt;   ?&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-weight: bold;"&gt;OR&lt;/span&gt;&lt;br /&gt;PHP also provide a function to create MySQL database, &lt;span class="phpcode"&gt;mysql_create_db()&lt;/span&gt;.    This function is deprecated though. It is better to use &lt;span class="phpcode"&gt;mysql_query()&lt;/span&gt;    to execute an SQL CREATE DATABASE statement instead like the above example.&lt;br /&gt;&lt;/p&gt; &lt;div class="codebox"&gt;    &lt;p&gt;&lt;?php&lt;br /&gt;   include 'config.php';&lt;br /&gt;   include 'opendb.php';&lt;br /&gt;  &lt;br /&gt;   &lt;strong&gt;mysql_create_db('&lt;/strong&gt;&lt;strong&gt;rajdb&lt;/strong&gt;&lt;strong&gt;');&lt;/strong&gt;&lt;/p&gt;   &lt;p&gt;include 'closedb.php';&lt;br /&gt;   ?&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-weight: bold;"&gt;Creating Table using PHP Code&lt;br /&gt;&lt;/span&gt;&lt;/p&gt; &lt;div class="codebox"&gt;    &lt;p&gt;&lt;?php&lt;br /&gt;   include 'config.php';&lt;br /&gt;   include 'opendb.php';&lt;/p&gt;    &lt;p&gt;$query  = 'CREATE DATABASE rajdb';&lt;br /&gt;   $result = mysql_query($query);&lt;br /&gt;  &lt;br /&gt;   &lt;strong&gt;mysql_select_db('rajdb') or die('Cannot select database'); &lt;/strong&gt;&lt;br /&gt;  &lt;br /&gt;   $query = 'CREATE TABLE info( '.&lt;br /&gt;            'infoid INT NOT NULL AUTO_INCREMENT,     '.&lt;br /&gt;            'name VARCHAR(20) NOT     NULL, '.&lt;br /&gt;         'PRIMARY KEY(infoid))';&lt;br /&gt;  &lt;br /&gt;   $result = mysql_query($query);&lt;br /&gt;  &lt;br /&gt;   include 'closedb.php';&lt;br /&gt;   ?&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt;&lt;span style="font-weight: bold;"&gt;Deleting a Database:&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;strong&gt;$query  = 'DROP DATABASE rajdb';&lt;/strong&gt;&lt;br /&gt;    $result = mysql_query($query);&lt;br /&gt; &lt;/p&gt;   &lt;/div&gt;   &lt;/div&gt; &lt;p&gt; &lt;/p&gt;   &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115625492857855213?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115625492857855213/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115625492857855213' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115625492857855213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115625492857855213'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/08/create-databasetable-with-php.html' title='Create Database/Table With PHP'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115504508694823457</id><published>2006-08-08T06:47:00.000-07:00</published><updated>2006-08-08T06:51:26.986-07:00</updated><title type='text'>PDF generation in PHP without any Library</title><content type='html'>####### PDF.php ##########&lt;br /&gt;&lt;?php&lt;br /&gt;/**&lt;br /&gt; * PDF::&lt;br /&gt; *&lt;br /&gt; * The PDF:: class provides a PHP-only implementation of a PDF library.&lt;br /&gt; * No external libs or PHP extensions are required.&lt;br /&gt; *&lt;br /&gt; * Based on the FPDF class by Olivier Plathey (http://www.fpdf.org) and the&lt;br /&gt; * Horde Framework PDF package (http://www.horde.org)&lt;br /&gt; *&lt;br /&gt; * Copyright 2003 Marko Djukic &lt;marko@oblo.com&gt;&lt;br /&gt; * Copyright 2003 Olivier Plathey &lt;olivier@fpdf.org&gt;&lt;br /&gt; *&lt;br /&gt; * See the enclosed file COPYING for license information (LGPL). If you did not&lt;br /&gt; * receive this file, see http://www.fsf.org/copyleft/lgpl.html.&lt;br /&gt; *&lt;br /&gt; * @author  Olivier Plathey &lt;olivier@fpdf.org&gt;&lt;br /&gt; * @author  Marko Djukic &lt;marko@oblo.com&gt;&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;class PDF {&lt;br /&gt;&lt;br /&gt;    var $_buffer = '';          // Buffer holding in-memory PDF.&lt;br /&gt;    var $_state = 0;            // Current document state.&lt;br /&gt;    var $_page = 0;             // Current page number.&lt;br /&gt;    var $_n = 2;                // Current object number.&lt;br /&gt;    var $_offsets = array();    // Array of object offsets.&lt;br /&gt;    var $_pages = array();      // Array containing the pages.&lt;br /&gt;    var $_w;                    // Page width in points.&lt;br /&gt;    var $_h;                    // Page height in points&lt;br /&gt;    var $_fonts = array();      // An array of used fonts.&lt;br /&gt;    var $_font_family = '';     // Current font family.&lt;br /&gt;    var $_font_style = '';      // Current font style.&lt;br /&gt;    var $_current_font;         // Array with current font info.&lt;br /&gt;    var $_font_size = 12;       // Current font size in points.&lt;br /&gt;    var $_compress;             // Flag to compress or not.&lt;br /&gt;    var $_core_fonts = array('courier'      =&gt; 'Courier',&lt;br /&gt;                             'courierB'     =&gt; 'Courier-Bold',&lt;br /&gt;                             'courierI'     =&gt; 'Courier-Oblique',&lt;br /&gt;                             'courierBI'    =&gt; 'Courier-BoldOblique',&lt;br /&gt;                             'helvetica'    =&gt; 'Helvetica',&lt;br /&gt;                             'helveticaB'   =&gt; 'Helvetica-Bold',&lt;br /&gt;                             'helveticaI'   =&gt; 'Helvetica-Oblique',&lt;br /&gt;                             'helveticaBI'  =&gt; 'Helvetica-BoldOblique',&lt;br /&gt;                             'times'        =&gt; 'Times-Roman',&lt;br /&gt;                             'timesB'       =&gt; 'Times-Bold',&lt;br /&gt;                             'timesI'       =&gt; 'Times-Italic',&lt;br /&gt;                             'timesBI'      =&gt; 'Times-BoldItalic',&lt;br /&gt;                             'symbol'       =&gt; 'Symbol',&lt;br /&gt;                             'zapfdingbats' =&gt; 'ZapfDingbats');&lt;br /&gt;    var $_fill_color = '0 g';   // Color used on text and fills.&lt;br /&gt;    var $_draw_color = '0 G';   // Line draw color.&lt;br /&gt;    var $_line_width = 1;       // Drawing line width.&lt;br /&gt;    var $_images = array();     // An array of used images.&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Attempts to return a conrete PDF instance. It allows to set up the page&lt;br /&gt;     * format, the orientation and the units of measurement used in all the&lt;br /&gt;     * methods (except for the font sizes).&lt;br /&gt;     *&lt;br /&gt;     * Example:&lt;br /&gt;     * $pdf = &amp;PDF::factory('P', 'A4');&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param optional string $orientation  Default page orientation.&lt;br /&gt;     *                                      Possible values are (case&lt;br /&gt;     *                                      insensitive):&lt;br /&gt;     *                                        - P or Portrait (default)&lt;br /&gt;     *                                        - L or Landscape&lt;br /&gt;     * @param optional mixed format         The format used for pages. It can&lt;br /&gt;     *                                      be either one of the following&lt;br /&gt;     *                                      values (case insensitive):&lt;br /&gt;     *                                        - A3&lt;br /&gt;     *                                        - A4 (default)&lt;br /&gt;     *                                        - A5&lt;br /&gt;     *                                        - Letter&lt;br /&gt;     *                                        - Legal&lt;br /&gt;     *                                      or a custom format in the form of&lt;br /&gt;     *                                      a two-element array containing the&lt;br /&gt;     *                                      width and the height (expressed in&lt;br /&gt;     *                                      the unit given by unit).&lt;br /&gt;     */&lt;br /&gt;    function &amp;factory($orientation = 'P', $format = 'A4')&lt;br /&gt;    {&lt;br /&gt;        /* Create the PDF object. */&lt;br /&gt;        $pdf = &amp;new PDF();&lt;br /&gt;&lt;br /&gt;        /* Page format. */&lt;br /&gt;        $format = strtolower($format);&lt;br /&gt;        if ($format == 'a3') {           // A3 page size.&lt;br /&gt;            $format = array(841.89, 1190.55);&lt;br /&gt;        } elseif ($format == 'a4') {     // A4 page size.&lt;br /&gt;            $format = array(595.28, 841.89);&lt;br /&gt;        } elseif ($format == 'a5') {     // A5 page size.&lt;br /&gt;            $format = array(420.94, 595.28);&lt;br /&gt;        } elseif ($format == 'letter') { // Letter page size.&lt;br /&gt;            $format = array(612, 792);&lt;br /&gt;        } elseif ($format == 'legal') {  // Legal page size.&lt;br /&gt;            $format = array(612, 1008);&lt;br /&gt;        } else {&lt;br /&gt;            die(sprintf('Unknown page format: %s', $format));&lt;br /&gt;        }  &lt;br /&gt;        $pdf-&gt;_w = $format[0];&lt;br /&gt;        $pdf-&gt;_h = $format[1];&lt;br /&gt;&lt;br /&gt;        /* Page orientation. */&lt;br /&gt;        $orientation = strtolower($orientation);&lt;br /&gt;        if ($orientation == 'l' || $orientation == 'landscape') {&lt;br /&gt;            $w = $pdf-&gt;_w;&lt;br /&gt;            $pdf-&gt;_w = $pdf-&gt;_h;&lt;br /&gt;            $pdf-&gt;_h = $w;&lt;br /&gt;        } elseif ($orientation != 'p' &amp;&amp;amp; $orientation != 'portrait') {&lt;br /&gt;            die(sprintf('Incorrect orientation: %s', $orientation));&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /* Turn on compression by default. */&lt;br /&gt;        $pdf-&gt;setCompression(true);&lt;br /&gt;&lt;br /&gt;        return $pdf;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Activates or deactivates page compression. When activated, the internal&lt;br /&gt;     * representation of each page is compressed, which leads to a compression&lt;br /&gt;     * ratio of about 2 for the resulting document.&lt;br /&gt;     * Compression is on by default.&lt;br /&gt;     * Note: the Zlib extension is required for this feature. If not present,&lt;br /&gt;     * compression will be turned off.&lt;br /&gt;     *&lt;br /&gt;     * @param bool $compress  Boolean indicating if compression must be&lt;br /&gt;     *                        enabled or not.&lt;br /&gt;     */&lt;br /&gt;    function setCompression($compress)&lt;br /&gt;    {  &lt;br /&gt;        /* If no gzcompress function is available then default to&lt;br /&gt;         * false. */&lt;br /&gt;        $this-&gt;_compress = (function_exists('gzcompress') ? $compress : false);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * This method begins the generation of the PDF document; it must be&lt;br /&gt;     * called before any output commands. No page is created by this method,&lt;br /&gt;     * therefore it is necessary to call PDF::addPage.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     */&lt;br /&gt;    function open()&lt;br /&gt;    {  &lt;br /&gt;        $this-&gt;_state = 1;          // Set state to initialised.&lt;br /&gt;        $this-&gt;_out('%PDF-1.3');    // Output the PDF header.&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Adds a new page to the document. The font which was set before calling&lt;br /&gt;     * is automatically restored. There is no need to call PDF::setFont again&lt;br /&gt;     * if you want to continue with the same font.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     */&lt;br /&gt;    function addPage()&lt;br /&gt;    {  &lt;br /&gt;        $this-&gt;_page++;                    // Increment page count.&lt;br /&gt;        $this-&gt;_pages[$this-&gt;_page] = '';  // Start the page buffer.&lt;br /&gt;        $this-&gt;_state = 2;                 // Set state to page&lt;br /&gt;                                           // opened.&lt;br /&gt;        /* Check if font has been set before this page. */&lt;br /&gt;        if ($this-&gt;_font_family) {&lt;br /&gt;            $this-&gt;setFont($this-&gt;_font_family, $this-&gt;_font_style, $this-&gt;_font_size);&lt;br /&gt;        }&lt;br /&gt;        /* Check if fill color has been set before this page. */&lt;br /&gt;        if ($this-&gt;_fill_color != '0 g') {&lt;br /&gt;            $this-&gt;_out($this-&gt;_fill_color);&lt;br /&gt;        }  &lt;br /&gt;        /* Check if draw color has been set before this page. */&lt;br /&gt;        if ($this-&gt;_draw_color != '0 G') {&lt;br /&gt;            $this-&gt;_out($this-&gt;_draw_color);&lt;br /&gt;        }&lt;br /&gt;        /* Check if line width has been set before this page. */&lt;br /&gt;        if ($this-&gt;_line_width != 1) {&lt;br /&gt;            $this-&gt;_out($this-&gt;_line_width);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Sets the font used to print character strings. It is mandatory to call&lt;br /&gt;     * this method at least once before printing text or the resulting&lt;br /&gt;     * document would not be valid. The font must be a standard one. Standard&lt;br /&gt;     * fonts use Windows encoding cp1252 (Western Europe).&lt;br /&gt;     * The method can be called before the first page is created and the font&lt;br /&gt;     * is retained from page to page.&lt;br /&gt;     * If you just wish to change the current font size, it is simpler to call&lt;br /&gt;     * PDF::setFontSize.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param string $family          Family font. It must be one of the&lt;br /&gt;     *                                standard families (case insensitive):&lt;br /&gt;     *                                  - Courier (fixed-width)&lt;br /&gt;     *                                  - Helvetica or Arial (sans serif)&lt;br /&gt;     *                                  - Times (serif)&lt;br /&gt;     *                                  - Symbol (symbolic)&lt;br /&gt;     *                                  - ZapfDingbats (symbolic)&lt;br /&gt;     *                                It is also possible to pass an empty&lt;br /&gt;     *                                string. In that case, the current&lt;br /&gt;     *                                family is retained.&lt;br /&gt;     * @param optional string $style  Font style. Possible values are (case&lt;br /&gt;     *                                insensitive):&lt;br /&gt;     *                                  - empty string: regular&lt;br /&gt;     *                                  - B: bold&lt;br /&gt;     *                                  - I: italic&lt;br /&gt;     *                                or any combination. The default value is&lt;br /&gt;     *                                regular. Bold and italic styles do not&lt;br /&gt;     *                                apply to Symbol and ZapfDingbats.&lt;br /&gt;     * @param optional int $size      Font size in points. The default value&lt;br /&gt;     *                                is the current size. If no size has been&lt;br /&gt;     *                                specified since the beginning of the&lt;br /&gt;     *                                document, the value taken is 12.&lt;br /&gt;     */&lt;br /&gt;    function setFont($family, $style = '', $size = null)&lt;br /&gt;    {&lt;br /&gt;        $family = strtolower($family);&lt;br /&gt;        if ($family == 'arial') {               // Use helvetica.&lt;br /&gt;            $family = 'helvetica';&lt;br /&gt;        } elseif ($family == 'symbol' ||        // No styles for&lt;br /&gt;                  $family == 'zapfdingbats') {  // these two fonts.&lt;br /&gt;            $style = '';&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        $style = strtoupper($style);&lt;br /&gt;        if ($style == 'IB') {                   // Accept any order&lt;br /&gt;            $style = 'BI';                      // of B and I.&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        if (is_null($size)) {                   // No size specified,&lt;br /&gt;            $size = $this-&gt;_font_size;          // use current size.&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        if ($this-&gt;_font_family == $family &amp;&amp;amp;   // If font is already&lt;br /&gt;            $this-&gt;_font_style == $style &amp;&amp;amp;     // current font&lt;br /&gt;            $this-&gt;_font_size == $size) {       // simply return.&lt;br /&gt;            return;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /* Set the font key. */&lt;br /&gt;        $fontkey = $family . $style;&lt;br /&gt;&lt;br /&gt;        if (!isset($this-&gt;_fonts[$fontkey])) {  // Test if cached.&lt;br /&gt;            $i = count($this-&gt;_fonts) + 1;      // Increment font&lt;br /&gt;            $this-&gt;_fonts[$fontkey] = array(    // object count and&lt;br /&gt;                'i'    =&gt; $i,                   // store cache.&lt;br /&gt;                'name' =&gt; $this-&gt;_core_fonts[$fontkey]);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /* Store current font information. */&lt;br /&gt;        $this-&gt;_font_family  = $family;&lt;br /&gt;        $this-&gt;_font_style   = $style;&lt;br /&gt;        $this-&gt;_font_size    = $size;&lt;br /&gt;        $this-&gt;_current_font = $this-&gt;_fonts[$fontkey];&lt;br /&gt;&lt;br /&gt;        /* Output font information if at least one page has been&lt;br /&gt;         * defined. */&lt;br /&gt;        if ($this-&gt;_page &gt; 0) {&lt;br /&gt;            $this-&gt;_out(sprintf('BT /F%d %.2f Tf ET', $this-&gt;_current_font['i'], $this-&gt;_font_size));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Defines the size of the current font.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param float $size  The size (in points).&lt;br /&gt;     */&lt;br /&gt;    function setFontSize($size)&lt;br /&gt;    {&lt;br /&gt;        if ($this-&gt;_font_size == $size) {   // If already current&lt;br /&gt;            return;                         // size simply return.&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        $this-&gt;_font_size = $size;          // Set the font.&lt;br /&gt;&lt;br /&gt;        /* Output font information if at least one page has been&lt;br /&gt;         * defined. */&lt;br /&gt;        if ($this-&gt;_page &gt; 0) {&lt;br /&gt;            $this-&gt;_out(sprintf('BT /F%d %.2f Tf ET',&lt;br /&gt;                                $this-&gt;_current_font['i'],&lt;br /&gt;                                $this-&gt;_font_size));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Sets the fill color. Specifies the color for both filled areas and&lt;br /&gt;     * text. Depending on the colorspace called, the number of color component&lt;br /&gt;     * parameters required can be either 1, 3 or 4. The method can be called&lt;br /&gt;     * before the first page is created and the color is retained from page to&lt;br /&gt;     * page.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param string $cs          Indicates the colorspace which can be either&lt;br /&gt;     *                            'rgb', 'cmyk' or 'gray'. Defaults to 'rgb'.&lt;br /&gt;     * @param float $c1           First color component, floating point value&lt;br /&gt;     *                            between 0 and 1. Required for gray, rgb and&lt;br /&gt;     *                            cmyk.&lt;br /&gt;     * @param optional float $c2  Second color component, floating point value&lt;br /&gt;     *                            between 0 and 1. Required for rgb and cmyk.&lt;br /&gt;     * @param optional float $c3  Third color component, floating point value&lt;br /&gt;     *                            between 0 and 1. Required for rgb and cmyk.&lt;br /&gt;     * @param optional float $c4  Fourth color component, floating point value&lt;br /&gt;     *                            between 0 and 1. Required for cmyk.&lt;br /&gt;     */&lt;br /&gt;    function setFillColor($cs = 'rgb', $c1, $c2 = 0, $c3 = 0, $c4 = 0)&lt;br /&gt;    {&lt;br /&gt;        $cs = strtolower($cs);&lt;br /&gt;        if ($cs = 'rgb') {&lt;br /&gt;            /* Using a three component RGB color. */&lt;br /&gt;            $this-&gt;_fill_color = sprintf('%.3f %.3f %.3f rg',&lt;br /&gt;                                         $c1, $c2, $c3);&lt;br /&gt;        } elseif ($cs = 'cmyk') {&lt;br /&gt;            /* Using a four component CMYK color. */&lt;br /&gt;            $this-&gt;_fill_color = sprintf('%.3f %.3f %.3f %.3f k',&lt;br /&gt;                                         $c1, $c2, $c3, $c4);&lt;br /&gt;        } else {&lt;br /&gt;            /* Grayscale one component color. */&lt;br /&gt;            $this-&gt;_fill_color = sprintf('%.3f g', $c1);&lt;br /&gt;        }&lt;br /&gt;        /* If document started output to buffer. */&lt;br /&gt;        if ($this-&gt;_page &gt; 0) {&lt;br /&gt;            $this-&gt;_out($this-&gt;_fill_color);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Sets the draw color, used when drawing lines. Depending on the&lt;br /&gt;     * colorspace called, the number of color component parameters required&lt;br /&gt;     * can be either 1, 3 or 4. The method can be called before the first page&lt;br /&gt;     * is created and the color is retained from page to page.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param string $cs          Indicates the colorspace which can be either&lt;br /&gt;     *                            'rgb', 'cmyk' or 'gray'. Defaults to 'rgb'.&lt;br /&gt;     * @param float $c1           First color component, floating point value&lt;br /&gt;     *                            between 0 and 1. Required for gray, rgb and&lt;br /&gt;     *                            cmyk.&lt;br /&gt;     * @param optional float $c2  Second color component, floating point value&lt;br /&gt;     *                            between 0 and 1. Required for rgb and cmyk.&lt;br /&gt;     * @param optional float $c3  Third color component, floating point value&lt;br /&gt;     *                            between 0 and 1. Required for rgb and cmyk.&lt;br /&gt;     * @param optional float $c4  Fourth color component, floating point value&lt;br /&gt;     *                            between 0 and 1. Required for cmyk.&lt;br /&gt;     */&lt;br /&gt;    function setDrawColor($cs = 'rgb', $c1, $c2 = 0, $c3 = 0, $c4 = 0)&lt;br /&gt;    {  &lt;br /&gt;        $cs = strtolower($cs);&lt;br /&gt;        if ($cs = 'rgb') {&lt;br /&gt;            $this-&gt;_draw_color = sprintf('%.3f %.3f %.3f RG',&lt;br /&gt;                                         $c1, $c2, $c3);&lt;br /&gt;        } elseif ($cs = 'cmyk') {&lt;br /&gt;            $this-&gt;_draw_color = sprintf('%.3f %.3f %.3f %.3f K',&lt;br /&gt;                                         $c1, $c2, $c3, $c4);&lt;br /&gt;        } else {&lt;br /&gt;            $this-&gt;_draw_color = sprintf('%.3f G', $c1);&lt;br /&gt;        }  &lt;br /&gt;        /* If document started output to buffer. */&lt;br /&gt;        if ($this-&gt;_page &gt; 0) {&lt;br /&gt;            $this-&gt;_out($this-&gt;_draw_color);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Defines the line width. By default, the value equals 1 pt. The method&lt;br /&gt;     * can be called before the first page is created and the value is&lt;br /&gt;     * retained from page to page.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param float $width  The width.&lt;br /&gt;     */&lt;br /&gt;    function setLineWidth($width)&lt;br /&gt;    {&lt;br /&gt;        $this-&gt;_line_width = $width;&lt;br /&gt;        if ($this-&gt;_page &gt; 0) {&lt;br /&gt;            $this-&gt;_out(sprintf('%.2f w', $width));&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Prints a character string. The origin is on the left of the first&lt;br /&gt;     * character, on the baseline. This method allows to place a string&lt;br /&gt;     * precisely on the page.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param float $x      Abscissa of the origin.&lt;br /&gt;     * @param float $y      Ordinate of the origin.&lt;br /&gt;     * @param string $text  String to print.&lt;br /&gt;     */&lt;br /&gt;    function text($x, $y, $text)&lt;br /&gt;    {&lt;br /&gt;        $text = $this-&gt;_escape($text);    // Escape any harmful&lt;br /&gt;                                          // characters.&lt;br /&gt;&lt;br /&gt;        $out = sprintf('BT %.2f %.2f Td (%s) Tj ET',&lt;br /&gt;                       $x, $this-&gt;_h - $y, $text);&lt;br /&gt;        $this-&gt;_out($out);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Prints an image in the page. The upper-left corner and at least one of&lt;br /&gt;     * the dimensions must be specified; the height or the width can be&lt;br /&gt;     * calculated automatically in order to keep the image proportions.&lt;br /&gt;     * Supported format is JPEG.&lt;br /&gt;     *&lt;br /&gt;     * For JPEG, all flavors are allowed:&lt;br /&gt;     *   - gray scales&lt;br /&gt;     *   - true colors (24 bits)&lt;br /&gt;     *   - CMYK (32 bits)&lt;br /&gt;     *&lt;br /&gt;     * The format will be inferred from the file extension.&lt;br /&gt;     *&lt;br /&gt;     * Remark: if an image is used several times, only one copy will be&lt;br /&gt;     * embedded in the file.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param string $file            Name of the file containing the image.&lt;br /&gt;     * @param float $x                Abscissa of the upper-left corner.&lt;br /&gt;     * @param float $y                Ordinate of the upper-left corner.&lt;br /&gt;     * @param float $width            Width of the image in the page. If equal&lt;br /&gt;     *                                to zero, it is automatically calculated&lt;br /&gt;     *                                to keep the original proportions.&lt;br /&gt;     * @param optional float $height  Height of the image in the page. If not&lt;br /&gt;     *                                specified or equal to zero, it is&lt;br /&gt;     *                                automatically calculated to keep the&lt;br /&gt;     *                                original proportions.&lt;br /&gt;     */&lt;br /&gt;    function image($file, $x, $y, $width = 0, $height = 0)&lt;br /&gt;    {&lt;br /&gt;        if (!isset($this-&gt;_images[$file])) {&lt;br /&gt;            /* First use of requested image, get the extension. */&lt;br /&gt;            if (($pos = strrpos($file, '.')) === false) {&lt;br /&gt;                die(sprintf('Image file %s has no extension and no type was specified', $file));&lt;br /&gt;            }&lt;br /&gt;            $type = strtolower(substr($file, $pos + 1));&lt;br /&gt;&lt;br /&gt;            /* Check the image type and parse. */&lt;br /&gt;            if ($type == 'jpg') {&lt;br /&gt;            $info = $this-&gt;_parseJPG($file);&lt;br /&gt;        } else {&lt;br /&gt;              die(sprintf('Unsupported image file type: %s', $type));&lt;br /&gt;          }&lt;br /&gt;            /* Set the image object id. */&lt;br /&gt;            $info['i'] = count($this-&gt;_images) + 1;&lt;br /&gt;            /* Set image to array. */&lt;br /&gt;&lt;br /&gt;            $this-&gt;_images[$file] = $info;&lt;br /&gt;        } else {&lt;br /&gt;            $info = $this-&gt;_images[$file];          // Known image, retrieve&lt;br /&gt;                                                    // from array.&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /* If not specified, do automatic width and height&lt;br /&gt;         * calculations, either setting to original or&lt;br /&gt;         * proportionally scaling to one or the other given&lt;br /&gt;         * dimension. */&lt;br /&gt;        if (empty($width) &amp;&amp;amp; empty($height)) {&lt;br /&gt;            $width = $info['w'];&lt;br /&gt;            $height = $info['h'];&lt;br /&gt;        } elseif (empty($width)) {&lt;br /&gt;            $width = $height * $info['w'] / $info['h'];&lt;br /&gt;        } elseif (empty($height)) {&lt;br /&gt;            $height = $width * $info['h'] / $info['w'];&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        $this-&gt;_out(sprintf('q %.2f 0 0 %.2f %.2f %.2f cm /I%d Do Q', $width, $height, $x, $this-&gt;_h - ($y + $height), $info['i']));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Draws a line between two points.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param float $x1  Abscissa of first point.&lt;br /&gt;     * @param float $y1  Ordinate of first point.&lt;br /&gt;     * @param float $x2  Abscissa of second point.&lt;br /&gt;     * @param float $y2  Ordinate of second point.&lt;br /&gt;     *&lt;br /&gt;     */                          &lt;br /&gt;    function line($x1, $y1, $x2, $y2)&lt;br /&gt;    {  &lt;br /&gt;        $this-&gt;_out(sprintf('%.2f %.2f m %.2f %.2f l S', $x1, $this-&gt;_h - $y1, $x2, $this-&gt;_h - $y2));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**                          &lt;br /&gt;     * Outputs a rectangle. It can be drawn (border only), filled (with no&lt;br /&gt;     * border) or both.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param float $x                Abscissa of upper left corner.&lt;br /&gt;     * @param float $y                Ordinate of upper left corner.&lt;br /&gt;     * @param float $width            Width.&lt;br /&gt;     * @param float $height           Height.&lt;br /&gt;     * @param optional string $style  Style of rendering. Possible values are:&lt;br /&gt;     *                                  - D or empty string: draw (default)&lt;br /&gt;     *                                  - F: fill&lt;br /&gt;     *                                  - DF or FD: draw and fill&lt;br /&gt;     */&lt;br /&gt;    function rect($x, $y, $width, $height, $style = '')&lt;br /&gt;    {&lt;br /&gt;        $style = strtolower($style);&lt;br /&gt;        if ($style == 'f') {&lt;br /&gt;            $op = 'f';      // Style is fill only.&lt;br /&gt;        } elseif ($style == 'fd' || $style == 'df') {&lt;br /&gt;            $op = 'B';      // Style is fill and stroke.&lt;br /&gt;        } else {&lt;br /&gt;            $op = 'S';      // Style is stroke only.&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        $this-&gt;_out(sprintf('%.2f %.2f %.2f %.2f re %s', $x, $this-&gt;_h - $y, $width, -$height, $op));&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Outputs a circle. It can be drawn (border only), filled (with no&lt;br /&gt;     * border) or both.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     *&lt;br /&gt;     * @param float $x                Abscissa of the center of the circle.&lt;br /&gt;     * @param float $y                Ordinate of the center of the circle.&lt;br /&gt;     * @param float $r                Circle radius.&lt;br /&gt;     * @param optional string $style  Style of rendering. Possible values are:&lt;br /&gt;     *                                  - D or empty string: draw (default)&lt;br /&gt;     *                                  - F: fill&lt;br /&gt;     *                                  - DF or FD: draw and fill&lt;br /&gt;     */&lt;br /&gt;    function circle($x, $y, $r, $style = '')&lt;br /&gt;    {&lt;br /&gt;        $style = strtolower($style);&lt;br /&gt;        if ($style == 'f') {&lt;br /&gt;            $op = 'f';      // Style is fill only.&lt;br /&gt;        } elseif ($style == 'fd' || $style == 'df') {&lt;br /&gt;            $op = 'B';      // Style is fill and stroke.&lt;br /&gt;        } else {&lt;br /&gt;            $op = 'S';      // Style is stroke only.&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        $y = $this-&gt;_h - $y;                 // Adjust y value.&lt;br /&gt;        $b = $r * 0.552;                     // Length of the Bezier&lt;br /&gt;                                             // controls.&lt;br /&gt;        /* Move from the given origin and set the current point&lt;br /&gt;         * to the start of the first Bezier curve. */&lt;br /&gt;        $c = sprintf('%.2f %.2f m', $x - $r, $y);&lt;br /&gt;        $x = $x - $r;&lt;br /&gt;        /* First circle quarter. */&lt;br /&gt;        $c .= sprintf(' %.2f %.2f %.2f %.2f %.2f %.2f c',&lt;br /&gt;                      $x, $y + $b,           // First control point.&lt;br /&gt;                      $x + $r - $b, $y + $r, // Second control point.&lt;br /&gt;                      $x + $r, $y + $r);     // Final point.&lt;br /&gt;        /* Set x/y to the final point. */&lt;br /&gt;        $x = $x + $r;&lt;br /&gt;        $y = $y + $r;&lt;br /&gt;        /* Second circle quarter. */&lt;br /&gt;        $c .= sprintf(' %.2f %.2f %.2f %.2f %.2f %.2f c',&lt;br /&gt;                      $x + $b, $y,&lt;br /&gt;                      $x + $r, $y - $r + $b,&lt;br /&gt;                      $x + $r, $y - $r);&lt;br /&gt;        /* Set x/y to the final point. */&lt;br /&gt;        $x = $x + $r;&lt;br /&gt;        $y = $y - $r;&lt;br /&gt;        /* Third circle quarter. */&lt;br /&gt;        $c .= sprintf(' %.2f %.2f %.2f %.2f %.2f %.2f c',&lt;br /&gt;                      $x, $y - $b,&lt;br /&gt;                      $x - $r + $b, $y - $r,&lt;br /&gt;                      $x - $r, $y - $r);&lt;br /&gt;        /* Set x/y to the final point. */&lt;br /&gt;        $x = $x - $r;&lt;br /&gt;        $y = $y - $r;&lt;br /&gt;        /* Fourth circle quarter. */&lt;br /&gt;        $c .= sprintf(' %.2f %.2f %.2f %.2f %.2f %.2f c %s',&lt;br /&gt;                      $x - $b, $y,&lt;br /&gt;                      $x - $r, $y + $r - $b,&lt;br /&gt;                      $x - $r, $y + $r,&lt;br /&gt;                      $op);&lt;br /&gt;        /* Output the whole string. */&lt;br /&gt;        $this-&gt;_out($c);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Terminates the PDF document. It is not necessary to call this method&lt;br /&gt;     * explicitly because PDF::output does it automatically.&lt;br /&gt;     * If the document contains no page, PDF::addPage is called to prevent&lt;br /&gt;     * from getting an invalid document.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     */&lt;br /&gt;    function close()&lt;br /&gt;    {&lt;br /&gt;        if ($this-&gt;_page == 0) {    // If not yet initialised, add&lt;br /&gt;            $this-&gt;addPage();       // one page to make this a valid&lt;br /&gt;        }                           // PDF.&lt;br /&gt;&lt;br /&gt;        $this-&gt;_state = 1;          // Set the state page closed.&lt;br /&gt;&lt;br /&gt;        /* Pages and resources. */&lt;br /&gt;        $this-&gt;_putPages();&lt;br /&gt;        $this-&gt;_putResources();&lt;br /&gt;&lt;br /&gt;        /* Print some document info. */&lt;br /&gt;        $this-&gt;_newobj();&lt;br /&gt;        $this-&gt;_out('&lt;&lt;');&lt;br /&gt;        $this-&gt;_out('/Producer (My First PDF Class)');&lt;br /&gt;        $this-&gt;_out(sprintf('/CreationDate (D:%s)',&lt;br /&gt;                            date('YmdHis')));&lt;br /&gt;        $this-&gt;_out('&gt;&gt;');&lt;br /&gt;        $this-&gt;_out('endobj');&lt;br /&gt;&lt;br /&gt;        /* Print catalog. */&lt;br /&gt;        $this-&gt;_newobj();&lt;br /&gt;        $this-&gt;_out('&lt;&lt;');&lt;br /&gt;        $this-&gt;_out('/Type /Catalog');&lt;br /&gt;        $this-&gt;_out('/Pages 1 0 R');&lt;br /&gt;        $this-&gt;_out('/OpenAction [3 0 R /FitH null]');&lt;br /&gt;        $this-&gt;_out('/PageLayout /OneColumn');&lt;br /&gt;        $this-&gt;_out('&gt;&gt;');&lt;br /&gt;        $this-&gt;_out('endobj');&lt;br /&gt;&lt;br /&gt;        /* Print cross reference. */&lt;br /&gt;        $start_xref = strlen($this-&gt;_buffer); // Get the xref offset.&lt;br /&gt;        $this-&gt;_out('xref');                  // Announce the xref.&lt;br /&gt;        $this-&gt;_out('0 ' . ($this-&gt;_n + 1));  // Number of objects.&lt;br /&gt;        $this-&gt;_out('0000000000 65535 f ');&lt;br /&gt;        /* Loop through all objects and output their offset. */&lt;br /&gt;        for ($i = 1; $i &lt;= $this-&gt;_n; $i++) {&lt;br /&gt;            $this-&gt;_out(sprintf('%010d 00000 n ', $this-&gt;_offsets[$i]));&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /* Print trailer. */&lt;br /&gt;        $this-&gt;_out('trailer');&lt;br /&gt;        $this-&gt;_out('&lt;&lt;');&lt;br /&gt;        /* The total number of objects. */&lt;br /&gt;        $this-&gt;_out('/Size ' . ($this-&gt;_n + 1));&lt;br /&gt;        /* The root object. */&lt;br /&gt;        $this-&gt;_out('/Root ' . $this-&gt;_n . ' 0 R');&lt;br /&gt;        /* The document information object. */&lt;br /&gt;        $this-&gt;_out('/Info ' . ($this-&gt;_n - 1) . ' 0 R');&lt;br /&gt;        $this-&gt;_out('&gt;&gt;');&lt;br /&gt;        $this-&gt;_out('startxref');&lt;br /&gt;        $this-&gt;_out($start_xref);  // Where to find the xref.&lt;br /&gt;        $this-&gt;_out('%%EOF');&lt;br /&gt;        $this-&gt;_state = 3;         // Set the document state to&lt;br /&gt;                                   // closed.&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    /**&lt;br /&gt;     * Function to output the buffered data to the browser.&lt;br /&gt;     *&lt;br /&gt;     * @access public&lt;br /&gt;     */&lt;br /&gt;    function output($filename)&lt;br /&gt;    {&lt;br /&gt;        if ($this-&gt;_state &lt; 3) {    // If document not yet closed&lt;br /&gt;            $this-&gt;close();         // close it now.&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /* Make sure no content already sent. */&lt;br /&gt;        if (headers_sent()) {&lt;br /&gt;            die('Unable to send PDF file, some data has already been output to browser.');&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /* Offer file for download and do some browser checks&lt;br /&gt;         * for correct download. */&lt;br /&gt;        $agent = trim($_SERVER['HTTP_USER_AGENT']);&lt;br /&gt;        if ((preg_match('|MSIE ([0-9.]+)|', $agent, $version)) ||&lt;br /&gt;            (preg_match('|Internet Explorer/([0-9.]+)|', $agent, $version))) {&lt;br /&gt;            header('Content-Type: application/x-msdownload');&lt;br /&gt;            Header('Content-Length: ' . strlen($this-&gt;_buffer));&lt;br /&gt;            if ($version == '5.5') {&lt;br /&gt;                header('Content-Disposition: filename="' . $filename . '"');&lt;br /&gt;            } else {&lt;br /&gt;                header('Content-Disposition: attachment; filename="' . $filename . '"');&lt;br /&gt;            }&lt;br /&gt;        } else {&lt;br /&gt;            Header('Content-Type: application/pdf');&lt;br /&gt;            Header('Content-Length: ' . strlen($this-&gt;_buffer));&lt;br /&gt;            Header('Content-disposition: attachment; filename=' . $filename);&lt;br /&gt;        }&lt;br /&gt;        echo $this-&gt;_buffer;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function _out($s)&lt;br /&gt;    {&lt;br /&gt;        if ($this-&gt;_state == 2) {&lt;br /&gt;            $this-&gt;_pages[$this-&gt;_page] .= $s . "\n";&lt;br /&gt;        } else {&lt;br /&gt;            $this-&gt;_buffer .= $s . "\n";&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function _escape($s)&lt;br /&gt;    {  &lt;br /&gt;        $s = str_replace('\\', '\\\\', $s);   // Escape any '\\'&lt;br /&gt;        $s = str_replace('(', '\\(', $s);     // Escape any '('&lt;br /&gt;        return str_replace(')', '\\)', $s);   // Escape any ')'&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    function _newobj()&lt;br /&gt;    {&lt;br /&gt;        /* Increment the object count. */&lt;br /&gt;        $this-&gt;_n++;&lt;br /&gt;        /* Save the byte offset of this object. */&lt;br /&gt;        $this-&gt;_offsets[$this-&gt;_n] = strlen($this-&gt;_buffer);&lt;br /&gt;        /* Output to buffer. */&lt;br /&gt;        $this-&gt;_out($this-&gt;_n . ' 0 obj');&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function _putPages()&lt;br /&gt;    {&lt;br /&gt;        /* If compression is required set the compression tag. */&lt;br /&gt;        $filter = ($this-&gt;_compress) ? '/Filter /FlateDecode ' : '';&lt;br /&gt;        /* Print out pages, loop through each. */&lt;br /&gt;        for ($n = 1; $n &lt;= $this-&gt;_page; $n++) {&lt;br /&gt;            $this-&gt;_newobj();                 // Start a new object.&lt;br /&gt;            $this-&gt;_out('&lt;&lt;/Type /Page');     // Object type.&lt;br /&gt;            $this-&gt;_out('/Parent 1 0 R');&lt;br /&gt;            $this-&gt;_out('/Resources 2 0 R');&lt;br /&gt;            $this-&gt;_out('/Contents ' . ($this-&gt;_n + 1) . ' 0 R&gt;&gt;');&lt;br /&gt;            $this-&gt;_out('endobj');&lt;br /&gt;&lt;br /&gt;            /* If compression required gzcompress() the page content. */&lt;br /&gt;            $p = ($this-&gt;_compress) ? gzcompress($this-&gt;_pages[$n]) : $this-&gt;_pages[$n];&lt;br /&gt;&lt;br /&gt;            /* Output the page content. */&lt;br /&gt;            $this-&gt;_newobj();                 // Start a new object.&lt;br /&gt;            $this-&gt;_out('&lt;&lt;' . $filter . '/Length ' . strlen($p) . '&gt;&gt;');&lt;br /&gt;            $this-&gt;_putStream($p);            // Output the page.&lt;br /&gt;            $this-&gt;_out('endobj');&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        /* Set the offset of the first object. */&lt;br /&gt;        $this-&gt;_offsets[1] = strlen($this-&gt;_buffer);&lt;br /&gt;        $this-&gt;_out('1 0 obj');&lt;br /&gt;        $this-&gt;_out('&lt;&lt;/Type /Pages');&lt;br /&gt;        $kids = '/Kids [';&lt;br /&gt;        for ($i = 0; $i &lt; $this-&gt;_page; $i++) {&lt;br /&gt;            $kids .= (3 + 2 * $i) . ' 0 R ';&lt;br /&gt;        }  &lt;br /&gt;        $this-&gt;_out($kids . ']');&lt;br /&gt;        $this-&gt;_out('/Count ' . $this-&gt;_page);&lt;br /&gt;        /* Output the page size. */&lt;br /&gt;        $this-&gt;_out(sprintf('/MediaBox [0 0 %.2f %.2f]',&lt;br /&gt;                            $this-&gt;_w, $this-&gt;_h));&lt;br /&gt;        $this-&gt;_out('&gt;&gt;');&lt;br /&gt;        $this-&gt;_out('endobj');&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function _putStream($s)&lt;br /&gt;    {&lt;br /&gt;        $this-&gt;_out('stream');&lt;br /&gt;        $this-&gt;_out($s);&lt;br /&gt;        $this-&gt;_out('endstream');&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function _putResources()&lt;br /&gt;    {&lt;br /&gt;        $this-&gt;_putFonts();              // Output any fonts.&lt;br /&gt;        $this-&gt;_putImages();             // Output any images.&lt;br /&gt;&lt;br /&gt;        /* Resources are always object number 2. */&lt;br /&gt;        $this-&gt;_offsets[2] = strlen($this-&gt;_buffer);&lt;br /&gt;        $this-&gt;_out('2 0 obj');&lt;br /&gt;        $this-&gt;_out('&lt;&lt;/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]');&lt;br /&gt;        $this-&gt;_out('/Font &lt;&lt;');&lt;br /&gt;        foreach ($this-&gt;_fonts as $font) {&lt;br /&gt;            $this-&gt;_out('/F' . $font['i'] . ' ' . $font['n'] . ' 0 R');&lt;br /&gt;        }&lt;br /&gt;        $this-&gt;_out('&gt;&gt;');&lt;br /&gt;        if (count($this-&gt;_images)) {     // Loop through any images&lt;br /&gt;            $this-&gt;_out('/XObject &lt;&lt;');  // and output the objects.&lt;br /&gt;            foreach ($this-&gt;_images as $image) {&lt;br /&gt;                $this-&gt;_out('/I' . $image['i'] . ' ' . $image['n'] . ' 0 R');&lt;br /&gt;            }&lt;br /&gt;            $this-&gt;_out('&gt;&gt;');&lt;br /&gt;        }&lt;br /&gt;        $this-&gt;_out('&gt;&gt;');&lt;br /&gt;        $this-&gt;_out('endobj');&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function _putFonts()&lt;br /&gt;    {&lt;br /&gt;        /* Print out font details. */&lt;br /&gt;        foreach ($this-&gt;_fonts as $k =&gt; $font) {&lt;br /&gt;            $this-&gt;_newobj();&lt;br /&gt;            $this-&gt;_fonts[$k]['n'] = $this-&gt;_n;&lt;br /&gt;            $name = $font['name'];&lt;br /&gt;            $this-&gt;_out('&lt;&lt;/Type /Font');&lt;br /&gt;            $this-&gt;_out('/BaseFont /' . $name);&lt;br /&gt;            $this-&gt;_out('/Subtype /Type1');&lt;br /&gt;            if ($name != 'Symbol' &amp;&amp;amp; $name != 'ZapfDingbats') {&lt;br /&gt;                $this-&gt;_out('/Encoding /WinAnsiEncoding');&lt;br /&gt;            }&lt;br /&gt;            $this-&gt;_out('&gt;&gt;');&lt;br /&gt;            $this-&gt;_out('endobj');&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function _putImages()&lt;br /&gt;    {&lt;br /&gt;        /* Output any images. */&lt;br /&gt;        $filter = ($this-&gt;_compress) ? '/Filter /FlateDecode ' : '';&lt;br /&gt;        foreach ($this-&gt;_images as $file =&gt; $info) {&lt;br /&gt;            $this-&gt;_newobj();&lt;br /&gt;            $this-&gt;_images[$file]['n'] = $this-&gt;_n;&lt;br /&gt;            $this-&gt;_out('&lt;&lt;/Type /XObject');&lt;br /&gt;            $this-&gt;_out('/Subtype /Image');&lt;br /&gt;            $this-&gt;_out('/Width ' . $info['w']);    // Image width.&lt;br /&gt;            $this-&gt;_out('/Height ' . $info['h']);   // Image height.&lt;br /&gt;            $this-&gt;_out('/ColorSpace /' . $info['cs']); //Colorspace&lt;br /&gt;            if ($info['cs'] == 'DeviceCMYK') {&lt;br /&gt;                $this-&gt;_out('/Decode [1 0 1 0 1 0 1 0]');&lt;br /&gt;            }  &lt;br /&gt;            $this-&gt;_out('/BitsPerComponent ' . $info['bpc']); // Bits&lt;br /&gt;            $this-&gt;_out('/Filter /' . $info['f']);  // Filter used.&lt;br /&gt;            $this-&gt;_out('/Length ' . strlen($info['data']) . '&gt;&gt;');&lt;br /&gt;            $this-&gt;_putStream($info['data']);       // Image data.&lt;br /&gt;            $this-&gt;_out('endobj');&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function _parseJPG($file)&lt;br /&gt;    {&lt;br /&gt;        /* Extract info from the JPEG file. */&lt;br /&gt;        $img = @getimagesize($file);&lt;br /&gt;      //  if (!$img) {&lt;br /&gt;        //    die(sprintf('Missing or incorrect image file: %s', $file));&lt;br /&gt;      //  }&lt;br /&gt;&lt;br /&gt;        /* Check if dealing with an actual JPEG. */&lt;br /&gt;       if ($img[2] != 2) {&lt;br /&gt;      die(sprintf('Not a JPEG file: %s', $file));&lt;br /&gt;       }&lt;br /&gt;        /* Get the image colorspace. */&lt;br /&gt;        if (!isset($img['channels']) || $img['channels'] == 3) {&lt;br /&gt;            $colspace = 'DeviceRGB';&lt;br /&gt;        } elseif ($img['channels'] == 4) {&lt;br /&gt;            $colspace = 'DeviceCMYK';&lt;br /&gt;        } else {&lt;br /&gt;            $colspace = 'DeviceGray';&lt;br /&gt;        }&lt;br /&gt;        $bpc = isset($img['bits']) ? $img['bits'] : 8;&lt;br /&gt;&lt;br /&gt;        /* Read the whole file. */&lt;br /&gt;        $f = fopen($file, 'rb');&lt;br /&gt;        $data = fread($f, filesize($file));&lt;br /&gt;        fclose($f);&lt;br /&gt;&lt;br /&gt;        return array('w' =&gt; $img[0], 'h' =&gt; $img[1], 'cs' =&gt; $colspace, 'bpc' =&gt; $bpc, 'f' =&gt; 'DCTDecode', 'data' =&gt; $data);&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;?&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;###################  mypdf.php ########&lt;br /&gt;&lt;?&lt;br /&gt;         require 'PDF.php';                   &lt;br /&gt;        $pdf = &amp;PDF::factory('p', 'a4');     &lt;br /&gt;        $pdf-&gt;open();                       &lt;br /&gt;        $pdf-&gt;setCompression(true);         &lt;br /&gt;        $pdf-&gt;addPage();     &lt;br /&gt;&lt;br /&gt;        $pdf-&gt;setFont('times', '', 15);    &lt;br /&gt;        $pdf-&gt;rect(25,20,350,200,'');&lt;br /&gt;        $pdf-&gt;text(235,140,' rajesh here ');&lt;br /&gt;        $pdf-&gt;setFont('Arial', '', 12);    &lt;br /&gt;        $pdf-&gt;text(125,65,'Welcome  ');&lt;br /&gt;&lt;br /&gt;      $pdf-&gt;output('try_pdf.pdf');   &lt;br /&gt;?&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115504508694823457?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115504508694823457/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115504508694823457' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115504508694823457'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115504508694823457'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/08/pdf-generation-in-php-without-any.html' title='PDF generation in PHP without any Library'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115493244634548033</id><published>2006-08-06T23:32:00.000-07:00</published><updated>2006-08-06T23:34:06.356-07:00</updated><title type='text'>http://code.google.com/hosting</title><content type='html'>&lt;span class="gensmall" style="line-height: 150%;"&gt;Google has launched a beta site service for open source software, called Google Code Project Hosting, available at &lt;/span&gt;&lt;table align="center" border="0" cellpadding="3" cellspacing="1" width="90%"&gt;&lt;tbody&gt;&lt;tr&gt;    &lt;td&gt;&lt;span class="genmed"&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr style="font-weight: bold;"&gt;   &lt;td class="code"&gt;http://code.google.com/hosting&lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;span class="postbody"&gt;Announced late last week at the O'Reilly Open Source Convention in Portland, Oregon and sporting a tagline of "Release Early, Release Often," Google Code provides space for developers and users to exchange open source software and collaboratively work on projects.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115493244634548033?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115493244634548033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115493244634548033' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115493244634548033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115493244634548033'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/08/httpcodegooglecomhosting.html' title='http://code.google.com/hosting'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115271544264382180</id><published>2006-07-12T07:40:00.000-07:00</published><updated>2006-07-12T07:44:02.656-07:00</updated><title type='text'>Configuring RoR</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Configuring the Application : &lt;/span&gt;&lt;br /&gt;Just follow these steps below:&lt;br /&gt;&lt;br /&gt;C:\ruby\work&gt;rails student&lt;br /&gt;&lt;br /&gt;C:\ruby\work&gt;cd student&lt;br /&gt;&lt;br /&gt;C:\ruby\work\student&gt;mysql -uroot&lt;br /&gt;&lt;br /&gt;mysql&gt; show databases;&lt;br /&gt;mysql&gt; create database student;&lt;br /&gt;&lt;br /&gt;mysql&gt;use student;&lt;br /&gt;&lt;br /&gt;mysql&gt; grant all on student.* to 'root'@'localhost';&lt;br /&gt;&lt;br /&gt;mysql&gt; exit&lt;br /&gt;&lt;br /&gt; ===== here you need to create the sql file i.e create.sql   ....\work\student\db\create.sql ===&lt;br /&gt;&lt;br /&gt;C:\ruby\work\student&gt;mysql student &lt;db/create.sql&lt;br /&gt;&lt;br /&gt;C:\ruby\work\student&gt;mysql -uroot&lt;br /&gt;&lt;br /&gt;mysql&gt; use student;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mysql&gt; show tables;&lt;br /&gt;&lt;br /&gt;mysql&gt; desc participants;&lt;br /&gt;&lt;br /&gt;mysql&gt; insert into participants values(111,'satish','pune');&lt;br /&gt;&lt;br /&gt;mysql&gt; insert into participants values(222,'rajesh','bangalore');&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;mysql&gt; select * from participants;&lt;br /&gt;&lt;br /&gt;mysql&gt; exit;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now open a file  .........\work\student\config\database.yml&lt;br /&gt;If you are getting database name as   student_development&lt;br /&gt;change it from&lt;br /&gt;     database: student_development  to database: student&lt;br /&gt;and save this file.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Run the weBrick server now by prompting below line:&lt;br /&gt;c:/rails/work/student&gt;ruby script/server&lt;br /&gt;&lt;br /&gt;Now scaffold should work:&lt;br /&gt;c:/rails/work/student&gt;ruby script/generate scaffold Participant Admin&lt;br /&gt;&lt;br /&gt;Open bowser&lt;br /&gt;http://localhost:3000/student&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(102, 102, 204);"&gt;OR go through this link &lt;/span&gt;&lt;strong style="font-weight: bold; color: rgb(102, 102, 204);"&gt;&lt;/strong&gt;&lt;br /&gt; &lt;span class="LightURL"&gt;&lt;a href="http://www.esnips.com/web/Programmingstuff"&gt;                                 http://www.esnips.com/web/Programmingstuff&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold; color: rgb(102, 102, 204);"&gt;OR&lt;br /&gt;just click on the icon right side of this blog "&lt;/span&gt;&lt;strong style="font-weight: bold; color: rgb(102, 102, 204);"&gt;&lt;a class="CommandLink" href="http://esnips.com/doc/19546048-154c-4320-96af-fabdd8697b0d/rail_config_steps.txt"&gt;&lt;strong&gt;rail_config_steps.txt&lt;/strong&gt;&lt;/a&gt;"&lt;/strong&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115271544264382180?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115271544264382180/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115271544264382180' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115271544264382180'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115271544264382180'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/07/configuring-ror.html' title='Configuring RoR'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115270781268055235</id><published>2006-07-12T05:34:00.000-07:00</published><updated>2006-07-12T05:36:52.683-07:00</updated><title type='text'>PHP_sorting arrays</title><content type='html'>&lt;ul&gt;   &lt;li&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;=========  sorting arrays ==============&lt;/span&gt;&lt;br /&gt;sort -- Sort an array&lt;br /&gt;rsort -- Sort an array in reverse order&lt;br /&gt;   &lt;br /&gt;asort -- Sort an array and maintain index association (no reverse)&lt;br /&gt;arsort --  Sort an array in reverse order and maintain index association&lt;br /&gt;           will sort an assositive array --values will be sorted not key&lt;br /&gt;ksort -- Sort an array by key&lt;br /&gt;krsort -- Sort an array by key in reverse order&lt;br /&gt;   &lt;br /&gt;usort --  Sort an array by values using a user-defined comparison function&lt;br /&gt;uksort --  Sort an array by keys using a user-defined comparison function&lt;/li&gt;   &lt;li&gt;&lt;span style="color: rgb(255, 255, 0);"&gt;========= require and include ===========&lt;/span&gt;&lt;br /&gt;require() statement includes and evaluates the specific file.&lt;br /&gt;   &lt;br /&gt;require() and include() are identical in every way except how they handle failure&lt;br /&gt;include() produces a Warning while require() results in a Fatal Error.&lt;br /&gt;   &lt;br /&gt;require_once() with the only difference being that if the code from a file has already been included, it will not be included again.&lt;br /&gt;  &lt;/li&gt; &lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115270781268055235?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115270781268055235/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115270781268055235' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115270781268055235'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115270781268055235'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/07/phpsorting-arrays.html' title='PHP_sorting arrays'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115270691567719128</id><published>2006-07-12T05:12:00.000-07:00</published><updated>2006-07-12T05:21:55.726-07:00</updated><title type='text'>echo VS print in PHP</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(255, 255, 0);"&gt;Difference btwn echo and print &lt;/span&gt;&lt;br /&gt;&lt;ul style="color: rgb(102, 255, 153);"&gt;   &lt;li&gt;print() behaves like a function in that you can do: $ret = print "Hello World";And $ret will be 1That means that print can be used as part of a more complex expression where echo cannot&lt;/li&gt;   &lt;li&gt;echo is marginally faster since it doesn't set a return value&lt;/li&gt;   &lt;li&gt;print is also part of the precedence table where as echo doesnt&lt;br /&gt;&lt;/li&gt; &lt;/ul&gt;&lt;span style="color: rgb(102, 255, 153);"&gt;echo ("raj"),("php");but you would simply write this as: echo "raj","php"; if you wanted to use two expression. Putting the brackets in there serves no purpose since there is no operator precendence issue with a single expression like that.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115270691567719128?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115270691567719128/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115270691567719128' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115270691567719128'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115270691567719128'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/07/echo-vs-print-in-php.html' title='echo VS print in PHP'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115269726808339598</id><published>2006-07-12T02:41:00.000-07:00</published><updated>2006-07-12T02:41:08.260-07:00</updated><title type='text'>Quick Ruby and Ruby on Rails</title><content type='html'>&lt;a href="http://punerb.blogspot.com/2006/07/configuring-application.html#links"&gt;Quick Ruby and Ruby on Rails&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115269726808339598?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115269726808339598/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115269726808339598' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115269726808339598'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115269726808339598'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/07/quick-ruby-and-ruby-on-rails.html' title='Quick Ruby and Ruby on Rails'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115167844314765290</id><published>2006-06-30T07:35:00.000-07:00</published><updated>2006-06-30T07:47:07.030-07:00</updated><title type='text'>Overloading Constructors</title><content type='html'>&lt;span style="font-weight: bold; color: rgb(102, 51, 255);"&gt;I tried the below Pgm. Just help me for my title Qs.&lt;br /&gt;# Constructors can be overloaded or not?&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;class MotorCycle&lt;br /&gt; #def initialize()&lt;br /&gt;  # puts 'no argument'&lt;br /&gt;#  end&lt;br /&gt;&lt;br /&gt; def initialize(just_one)&lt;br /&gt;      puts 'one argument'&lt;br /&gt; end&lt;br /&gt;&lt;br /&gt;puts "Just one constructor"&lt;br /&gt;#puts "With Two constructor"&lt;br /&gt;#obj1=MotorCycle.new();&lt;br /&gt;obj2=MotorCycle.new('one');&lt;br /&gt;&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;&lt;span style="color: rgb(255, 255, 102);"&gt;output 1: Putting the # as in above  code&lt;/span&gt;&lt;br /&gt;&lt;/span&gt; &lt;div style="text-align: left;"&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;&lt;br /&gt;C:\ruby\bp&gt;ruby cs.rb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;Just one constructor&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;one argument&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold; color: rgb(255, 255, 0);"&gt;output 2: Remove those  #  in above  code&lt;/span&gt;&lt;br /&gt;&lt;/div&gt; &lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;C:\ruby\bp&gt;ruby cs.rb&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;With Two constructor&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;cs.rb:12:in `initialize': wrong number of arguments (0 for 1) (ArgumentError)&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;        from cs.rb:12:in `new'&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;        from cs.rb:12&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;&lt;/span&gt;&lt;/div&gt; &lt;div style="text-align: left;"&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;&lt;/span&gt;&lt;/div&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115167844314765290?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115167844314765290/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115167844314765290' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115167844314765290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115167844314765290'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/06/overloading-constructors.html' title='Overloading Constructors'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115158386300058739</id><published>2006-06-29T05:24:00.000-07:00</published><updated>2006-06-29T05:29:49.553-07:00</updated><title type='text'>SWAP FILES</title><content type='html'>&lt;a href="http://blogging-raj.blogspot.com/"&gt;Ruby n RAJ&lt;/a&gt;&lt;br /&gt;&lt;span style="font-weight: bold; color: rgb(255, 255, 0);"&gt;#  swapping the contents of TWO files&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;# display before swapping &lt;/span&gt;&lt;br /&gt;puts'========== BEFORE SWAPPING ============'&lt;br /&gt;f1=File.open('file1.txt','r') do |f1|&lt;br /&gt; puts'FILE1 contents : '&lt;br /&gt; while(line=f1.gets)       &lt;br /&gt;    puts line&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;f2=File.open('file2.txt','r') do |f2|&lt;br /&gt; puts'FILE2 contents : '&lt;br /&gt; while(line=f2.gets)&lt;br /&gt;         puts line&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;# copy the contents of FILE1 to TEMP_FILE&lt;/span&gt;&lt;br /&gt;ftemp=File.open('temp.txt','w') do |ftemp|&lt;br /&gt;f1=File.open('file1.txt','r')   do |f1|&lt;br /&gt;       while(line=f1.gets)&lt;br /&gt;           ftemp.puts line&lt;br /&gt;   end&lt;br /&gt;   end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;# copy the contents of FILE2 to FILE1&lt;/span&gt;&lt;br /&gt;f1=File.open('file1.txt','w') do |f1|&lt;br /&gt;f2=File.open('file2.txt','r') do |f2|&lt;br /&gt;    while(line=f2.gets)&lt;br /&gt;             f1.puts line&lt;br /&gt;    end&lt;br /&gt;end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;# copy the contents of  TEMP_FILE to FILE2&lt;/span&gt;&lt;br /&gt;f2=File.open('file2.txt','w') do |f2|&lt;br /&gt;ftemp=File.open('temp.txt','r') do |ftemp|&lt;br /&gt;    while(line=ftemp.gets)&lt;br /&gt;             f2.puts line&lt;br /&gt;    end&lt;br /&gt; end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;span style="font-weight: bold;"&gt;# display AFTER swapping &lt;/span&gt;&lt;br /&gt;puts'========== AFTER SWAPPING ============'&lt;br /&gt;f1=File.open('file1.txt','r') do |f1|&lt;br /&gt; puts'FILE1 contents : '&lt;br /&gt; while(line=f1.gets)       &lt;br /&gt;    puts line&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;f2=File.open('file2.txt','r') do |f2|&lt;br /&gt; puts'FILE2 contents : '&lt;br /&gt; while(line=f2.gets)&lt;br /&gt;         puts line&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;                     &lt;span style="font-weight: bold; color: rgb(51, 255, 51);"&gt;   OUTPUT&lt;/span&gt;&lt;br /&gt;C:\ruby\bp&gt;ruby swapcontents.rb&lt;br /&gt;========== BEFORE SWAPPING ============&lt;br /&gt;FILE1 contents :&lt;br /&gt;I want to be a good programmer in RoR&lt;br /&gt;Please help me.&lt;br /&gt;FILE2 contents :&lt;br /&gt;Shall I proceed with Ruby or Not?&lt;br /&gt;========== AFTER SWAPPING ============&lt;br /&gt;FILE1 contents :&lt;br /&gt;Shall I proceed with Ruby or Not?&lt;br /&gt;FILE2 contents :&lt;br /&gt;I want to be a good programmer in RoR&lt;br /&gt;Please help me.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115158386300058739?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115158386300058739/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115158386300058739' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115158386300058739'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115158386300058739'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/06/swap-files.html' title='SWAP FILES'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115150526690676432</id><published>2006-06-28T07:31:00.000-07:00</published><updated>2006-06-28T07:34:26.913-07:00</updated><title type='text'>leap-year or not ?</title><content type='html'># Fact: A year is a leap year if it is divisible by 4, unless it is divisible by 100. However, years divisible by 400 are leap years.&lt;br /&gt;&lt;br /&gt;puts "Please enter the four digit Year "&lt;br /&gt;year_string = gets.chomp&lt;br /&gt;puts "You have entered , YEAR : " + year_string&lt;br /&gt;# convert the inputted string into integer&lt;br /&gt;year_integer=year_string.to_i&lt;br /&gt;&lt;br /&gt;if year_integer&lt;1000&lt;br /&gt;  puts "Invalid input!! Please reenter a 4 digit number"&lt;br /&gt;  exit&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;if(  (  ( year_integer%4==0)  and ( year_integer%100 != 0 )  )  or     (year_integer%400 == 0 )  )&lt;br /&gt;     puts "Its a leap year."&lt;br /&gt;else&lt;br /&gt;     puts "Its not a leap year"&lt;br /&gt;end&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115150526690676432?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115150526690676432/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115150526690676432' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115150526690676432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115150526690676432'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/06/leap-year-or-not.html' title='leap-year or not ?'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115141490069318893</id><published>2006-06-27T06:28:00.000-07:00</published><updated>2006-06-27T06:28:20.706-07:00</updated><title type='text'>Ashish's blog</title><content type='html'>&lt;a href="http://ashishkulkarni.blogspot.com/"&gt;Ashish's blog&lt;/a&gt;: "And how are dates stored?"&lt;br /&gt;Hi Ashish, raj here. Here is your doubt that cheered me while answering.&lt;br /&gt;below is the code for printing date:&lt;br /&gt;------------------------------------&lt;br /&gt;require 'date' &lt;br /&gt;&lt;br /&gt;#d = Date.new(2000, 3, 31) &lt;br /&gt;d = Date.today()&lt;br /&gt;puts d&lt;br /&gt;------------------------------------&lt;br /&gt;#To print time:&lt;br /&gt;&lt;br /&gt; puts Time.at(0)&lt;br /&gt;#here in bracket you can set the seconds with time. just put some random number n try to analyze output.&lt;br /&gt;------------------------------------&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115141490069318893?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115141490069318893/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115141490069318893' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115141490069318893'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115141490069318893'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/06/ashishs-blog.html' title='Ashish&apos;s blog'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-29695035.post-115028004641331324</id><published>2006-06-14T03:12:00.000-07:00</published><updated>2006-06-14T03:14:06.420-07:00</updated><title type='text'>Hi</title><content type='html'>Testing my blog&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/29695035-115028004641331324?l=blogging-raj.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blogging-raj.blogspot.com/feeds/115028004641331324/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=29695035&amp;postID=115028004641331324' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115028004641331324'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/29695035/posts/default/115028004641331324'/><link rel='alternate' type='text/html' href='http://blogging-raj.blogspot.com/2006/06/hi.html' title='Hi'/><author><name>raj</name><uri>http://www.blogger.com/profile/12331769001809161215</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://rajesh4it.googlepages.com/whathappen.jpg'/></author><thr:total>1</thr:total></entry></feed>
