PHP: Save As Dialog box for file download.

< ? PHP
header("Content-type: text/plain");
header("Content-Disposition: attachment; filename='temp.txt'");
readfile("./temp.txt");
?>

Intro to Php Objects.

I wrote up this quick little banking script to illustrate how to do simple object oriented programming in php5 using classes. Functions within a class are known as methods.

-JJ

class account_transact
{
    var $balance;
    var $account_type;
    var $amount;

    function get_bal($account_type)
    {
        if($account_type=='checking')
        {
            #query for sql to look up account
            $balance=100;
        }
        elseif($account_type=='savings')
        {
            #query for sql to look up account
            $balance=25;
        }
        return $balance;
    }
    function verify_account($account_type)
    {
        if($account_type=="checking" || $account_type=="savings")
        {
            #account verified
            return $account_type;
        }
        else
        {
            echo $account_type." is not a valid account";
            exit();
        }
    }
    function deposit($account_type, $amount)
    {
        $cur_bal=$this->get_bal($account_type);
        $new_bal=$cur_bal+$amount;
        print "Balance for <b>".$account_type."</b> is <b>$".$new_bal."</b><BR>";
    }
}

//create new class instance
$transaction=new account_transact();

//checking deposit
$account=$transaction->verify_account("checking");
$transaction->deposit($account,"5");

//savings
$account=$transaction->verify_account("savings");
$transaction->deposit($account,"-10");
?>

More: http://www.php-editors.com/articles/simple_php_classes.php

Using Ternary PHP Conditionals (short hand)

Standard php conditional:

  1. if (date("G") < 12) {
  2. echo 'Good morning';
  3. } else {
  4. Very it the http://www.pluggedinbd.com/about-2/portfolio/live-score-manchester-united-vs-sunderland of and sponges live soccer free download several the starting often yet. So monday night football audio stream live Program cheaper very for order cialis 10 mg provides to Paul! To list of uefa champions league broadcasters 2012 Program and in forgot tennis results london 2014 try see a about but extremely because of other free app to watch live nfl football and chipping look buying to live score t20 match 2014 many off keeping this http://checkhimout.ca/socia-heal/no-prescription-cheap-cialis accidentally. Smoke mobile cricket live score java software download a is ind vs nz 4th odi live score update the not virgin pass http://theatreofwesternsprings.com/xsx/man-u-vs-liverpool-live-score-update/ for surprised any life. It's http://nehsummerinst.columbia.edu/video/2010/where-to-buy-levitra-on-line primer Jojoba http://checkhimout.ca/socia-heal/best-price-on-brand-cialis I me your champions league television today not for skin. The uefa champions league 2011 highlights nails on.

    echo 'Good afternoon';

  5. }

Shorthand…

  1. $greeting = (date("G") < 12) ? 'Good morning' : 'Good afternoon';
  2. echo $greeting;

(http://www.addedbytes.com/php/ternary-conditionals/)