Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Pass by reference needed 15 Jun 2016 06:06 #14066

  • vlemos
  • vlemos's Avatar Topic Author
  • Online
  • Elite Member
  • Elite Member
  • Posts: 295
  • Thank you received: 41
$item was passed in by reference; should it not be passed by reference here as well?
public function populateObjects(&$item)
	{
		if (!empty($item->params) && is_string($item->params))
		{
			$registry = new JRegistry;
			$registry->loadString($item->params);
			$item->params = $registry->toObject();
		}
	
		parent::populateObjects($item);
	}
parent::populateObjects(&$item);

Please Log in or Create an account to join the conversation.

Pass by reference needed 15 Jun 2016 08:20 #14069

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
If you do that, PHP5 will throw a big error.

No, it is deprecated and finished this this when you use the '&' in the call. Only for arrays, and only for declarations of the parameters of the function.
All objects are pointer, so only simple vars and arrays need that. but only in the parameters declaration.

Even here in our case, I am not sure if it is required in the declaration. It is just a coding style for the coder to remember it is a OUTPUT parameter.
But when $item is an object, you can be sure it will be working even without '&' because it is systematically a pointer.
Coding is now a piece of cake
The following user(s) said Thank You: vlemos

Please Log in or Create an account to join the conversation.

Last edit: by admin.
  • Page:
  • 1
Time to create page: 0.082 seconds

Freakin' Awesome!!! J-Cook is simply awesome - whether you're a highly experienced developer or complete novice whether you're building a small inventory component or a complete community solution! The beauty comes from a fast slick and reliable platform that readily provides developers with everything they'll need to build the backbone of a solid and secure component with wizards for authoring access publishing aliasing created/modified by dates... you name it COOK provides it! J-Cook really surpasses all of the 'competition' as far as MVC tools are concerned! Try love it and get cooking!
learnthrusong (JED)
          

Get Started