Issue on OOP PHP -
i have class called captcha.php :
<?php class captcha { const first_num = 1; const second_num = 9; private $num1 = rand(first_num,second_num); private $num2 = rand(first_num,second_num); function creatnums(){ return $num1; } } in index.php tried instantiate class
<?php include_once('captcha.php'); $tat = new captcha(); $result = $tat->creatnums(); echo $result; but not returning/ echoing thing on page. can please let me know why happening?
thansk
<?php class captcha { const first_num = 1; const second_num = 9; private $num1; private $num2; function __construct(){ $this->num1 = rand(self::first_num, self::second_num); $this->num2 = rand(self::first_num, self::second_num); } function creatnums(){ return $this->num1; } } $tat = new captcha(); $result = $tat->creatnums(); echo $result;
Comments
Post a Comment