Jump to content

Recommended Posts

Posted

Dear Community,

Trying to do add some field values programmatically, it works fine like this:

// field 'author' does not exist in template
$page->author="{$page->author_first} {$page->author_last}";
echo $page->author;
// prints "John Doe"

due to my structure it would be nice to have this within a function with passing by reference, sadly it does not work like this:

function renderAuthorInfo(&$page)
{
	$page->author="{$page->author_first} {$page->author_last}";
}

renderAuthorInfo($page);
echo $page->author;
// Not working

What am I missing here? Or is it just not possible to do it like this with PHP objects?

The code is only an example, I'm not actually trying to put first and last name together, but something more complex.

Posted

Did couple of quick tests and there's no problem with this (just like @Soma pointed out above.) Sounds like it's something about your "more complex" thing that's broken.

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...