Jump to content

ivan444

New Members
  • Posts

    9
  • Joined

  • Last visited

ivan444's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. It works i just removed the include("index.php"); from class.php Thank you Barand
  2. I still got the error Fatal error: Maximum execution time of 30 seconds exceeded in H:\xampp\htdocs\NOVO\class.php on line 2 Can you copy paste what you have please here is the class.php <?php include("index.php"); class february { private $year; public function __construct($year) { $this->year = $year; } public function numDays() { $d = new DateTime("{$this->year}-02-01"); return $d->format('t'); } } ?>
  3. <?php include("class.php"); if (isset($_GET['year'])) { $f = new february((int)$_GET['year']); $days = $f->numdays(); echo "There were $days days in February {$_GET['year']}<hr>"; } $cutoff = date(1900); $now = date('Y'); ?> <html> <body> <form method='get' action=''> <?php echo '<select name="year">' . PHP_EOL; for ($y=$now; $y>=$cutoff; $y--) { echo ' <option value="' . $y . '">' . $y . '</option>' . PHP_EOL; } echo '</select>' . PHP_EOL; ?> </form> </body> </html>
  4. i copied your solution in my index.php script but i got this error Fatal error: Maximum execution time of 30 seconds exceeded in H:\xampp\htdocs\PHP1\index.php on line 2
  5. I really don't know.It just wont work. The thing is i need to make 2 node++ files. One is index.php where is the drop down with years from 1900 to 2015 and where i call the class february. And the second script is class.php where is the class...Here is the code in those scripts...please reply if you can fix my problem. class.php <?php include("index.php"); class february { private $year; public function __construct($year) { $this->year = $year; } public function numDays() { $d = new DateTime("{$this->year}-02-01"); return $d->format('t'); } } ?> index.php <?php include("class.php"); $cutoff = date(1900); $now = date('Y'); echo '<select name="year">' . PHP_EOL; for ($y=$now; $y>=$cutoff; $y--) { echo ' <option value="' . $y . '">' . $y . '</option>' . PHP_EOL; } echo '</select>' . PHP_EOL; $f = new february((int)$_POST['year']); echo $f->numdays(); ?>
  6. Yeah,but i need this code to work with a drop down list. When you click a year from 1900 to 2015 you should get number of days in february ?!
  7. I need this logic in Class not just the function This is the drop down list $cutoff = 1900; $now = date('Y'); // YEARS echo '<select name="year">' . PHP_EOL; for ($y=$now; $y>=$cutoff; $y--) { echo ' <option value="' . $y . '">' . $y . '</option>' . PHP_EOL; } echo '</select>' . PHP_EOL; Now i need to get number of days in february by clicking Only class varianty... please...tnx
  8. Hello guys I really need some help please I need to create a class, for example "yearCheckFeb" I have a drop down list with years from 1900 to 2015 and when you choose a year you must get number of days in february. Can someone help my with this,please Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.