class Mobil
{
    function ban()
    {
        echo "ma aing";
    }
    function panto()
    {
        // kode buntut
        $naonwe = "ma sia";
        return $naonwe;
    }
    function kaca_mobil($term)
    {
        $arr_val = '';
        if ($term == "array") {
            $arr_val = array('kode' => 'A', 'value' => 'A0');
        }
        return json_encode($arr_val);
    }
}
include "class/Mobil.php";
$mobil = new Mobil();
echo $mobil->ban();
$tampil = $mobil->panto();
echo "<br />" . $tampil;
$kaca = $mobil->kaca_mobil("array");
$kaca = json_decode($kaca);
echo $kaca->kode . "<br />";
echo $kaca->value;
示例#2
0
 /**
  * dailyUpdate
  *
  * 毎日基本使用料金を更新します
  *
  * @access	public
  * @return	void
  */
 public function dailyUpdateAction()
 {
     $today = date('Ymd');
     $day = date('d');
     $recs = MobilRate::query()->where("del_flg=0")->execute();
     foreach ($recs as $r) {
         $phoneno = $r->mobil_no;
         $spid = $r->sp_id;
         $from = $r->date_from;
         $to = $r->date_to;
         $base = $r->base_fee;
         $total = $r->including_tax;
         $remain = $r->remain_credit;
         $free = $r->remain_free;
         if ($day == 1) {
             // 毎月の1日なら、無料通話料をチャージします
             $mobils = Mobil::query()->where("sp_id= :sp_id:")->bind(array("sp_id" => $spid))->execute();
             $free = $mobils[0]->freefee;
         }
         $today_d = date_create($today);
         $to_d = date_create($to);
         $diff = date_diff($today_d, $to_d);
         if ($today_d > $to_d) {
             $myphones = Mobil::query()->where("sp_id= :sp_id: and mobil_no= :mobil_no:")->bind(array("sp_id" => $spid, "mobil_no" => $phoneno))->execute();
             $asum = $myphones[0]->asum;
             $mrs = MobilRate::query()->where("sp_id= :sp_id: and mobil_no= :mobil_no:")->bind(array("sp_id" => $spid, "mobil_no" => $phoneno))->execute();
             $mr = $mrs[0];
             $mr->date_to = $today;
             $diffbase = $asum / 30 * $diff->format('%d');
             $mr->base_fee = $base + $diffbase;
             $mr->including_tax = $total + $diffbase * 1.08;
             $mr->remain_free = $free;
             $mr->remain_credit = $remain - $diffbase * 1.08;
             $mr->save();
         }
     }
 }