Jump to content

Recommended Posts

check it out:

<?php
//begin the script for date and time
class datebones {
//day
var $dayfull = date('l');
//month
var $monthfull = date('F');
var $monthnumber = date('m');
//date
var $datenozero = date('j');
var $datewithzero = date('d');
//year
var $yearfull = date('Y');
var $yearshort = date('y');	
}

$datebones = &new datebones;
echo $datebones->dayfull;


?>

 

it is giving me the followin error:

or: syntax error, unexpected '(', expecting ',' or ';' in C:\xampp\htdocs\xampp\mystuff\eYaMod\dateandtime.php on line 5

 

any ideas? ???

thanks,

 

HoTDaWg

 

Link to comment
https://forums.phpfreaks.com/topic/52716-solved-noob-to-oop/
Share on other sites

What version of PHP are you using, if you are using 4, that will not work. Something like this would though

 

<?php
//begin the script for date and time
class datebones {
//day
var $dayfull = '';
//month
var $monthfull = '';
var $monthnumber = '';
//date
var $datenozero = '';
var $datewithzero = '';
//year
var $yearfull = '';
var $yearshort = '';

             function datebones() {
                 $this->dayfull = date('l');
                 $this->monthfull = date('F');
                 $this->monthnumber = date('m');
                 $this->datenozero = date('j');
                 $this->datewithzero = date('d');
                 $this->yearfull = date('Y');
                 $this->yearshort = date('y');
             }
}

$datebones = new datebones(); // why use the reference here?
echo $datebones->dayfull;

?>

 

Reason being PHP 4 does not pay attention to the definition of vars outside of function other than acknowleding that they are there. If you are using PHP5, wel I am sure it has something to do with the date function being there.

Link to comment
https://forums.phpfreaks.com/topic/52716-solved-noob-to-oop/#findComment-260279
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.