On Thu, 2003-03-27 at 18:32, Brian Moon wrote:
> Has type hinting for functions been implemented in ZE2?

Type hints apply to global functions just as they do for class methods.

<?php
  class Date { 
    private
      $utime    = 0;
      
    public function __construct($arg= -1) {
      if (is_int($arg)) {
        $this->utime= $arg < 0 ? time() : $arg;
      } else {
        $this->utime= strtotime($arg);
      }
    }
    
    public function toString($fmt= 'r') {
      return date($fmt, $this->utime);
    }
  }
  
  function print_date(Date $date, $fmt) {
    echo $date->toString($fmt);
  }
  
  print_date(new Date(), $argv[1]);
  echo "\n";
?>
[EMAIL PROTECTED]:~/devel/php > ./php5/sapi/cli/php date.php "Y-m-d"
2003-03-27

- Timm


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to