Wednesday, 15 September 2010

class - Make classes in php -



class - Make classes in php -

i origin create classes in php. have create reference class, have next error:

fatal error: class 'numbercode' not found in c:\...\mastermind.php on line 14

i have made code:

<?php class numbercode { public $code; function __construct() { print "ok"; } function makecode() { $counter = 1; while ($counter < 5) { $this->code = $this->code . rand(1, 6); print "ok"; $counter++; } } }

and here reference:

<?php $combination = new numbercode(); $combination -> makecode(); $code = $combination -> code; print $code ?>

i have seek print lines code , have used fiddler.

the file uses class needs include file defines class. typically require or require_once statement.

<?php require_once('path_to_class_file.php'); $combination = new numbercode(); $combination -> makecode(); $code = $combination -> code; print $code ?>

php class

No comments:

Post a Comment