Jump to content

Recommended Posts

Hello everyone :) I'm modifying an open source software called phpScheduleIt, I'm trying to change the machid function based on the $type variable and I'm getting this error below:

 

Parse error: syntax error, unexpected T_IF, expecting T_FUNCTION in C:\xampp\htdocs\phpScheduleIt\lib\Reservation.class.php on line 1122

 

1122	if ($type == RES_TYPE_ADD)
1123		function get_machid() {
1124			return $this->resource->get_property('machid');
1125		}
1126	if ($type == RES_TYPE_MODIFY)
1127		function get_machid() {
1128			return $this->machid;
1129		}

 

I don't understand why this isn't working :\

 

phpSchedule it is a really great free open source scheduling software if anyone is interested, full credits to Nick Korbel. http://php.brickhost.com

Link to comment
https://forums.phpfreaks.com/topic/261685-unexpected-t_if-expecting-t_function/
Share on other sites

You can't put if blocks directly inside a class definition. Instead, put them inside the get_machid() function like

function get_machid() {
if ($this->type == RES_TYPE_ADD) {
	return $this->resource->get_property('machid');
} else if ($this->type == RES_TYPE_MODIFY) {
	return $this->machid;
}
}

(assuming that the "type" variable is a member of the Reservation class and not, say, a function parameter you haven't mentioned)

Requinix I love you! You are my HERO! This works 100%

 

 

You can't put if blocks directly inside a class definition. Instead, put them inside the get_machid() function like

function get_machid() {
if ($this->type == RES_TYPE_ADD) {
	return $this->resource->get_property('machid');
} else if ($this->type == RES_TYPE_MODIFY) {
	return $this->machid;
}
}

(assuming that the "type" variable is a member of the Reservation class and not, say, a function parameter you haven't mentioned)

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.