Jump to content

Use ucfirst in a title


paulmagm
 Share

Recommended Posts

Thanks make sense. But crashed my site. But why? This is the hole context then.

  $data = [
            $content_slug = ucfirst($page['content_slug']);
            $content_title = ucfirst($page['content_title']);
            'title' => "{$content_slug} ({$content_title}) ",
            'meta.description' => $description,
            'page' => $page,
        ];

        return $app->render($template, $data);
    }

 

Link to comment
Share on other sites

Because of the semi-colon at the end of each declaration and those being declared inside $data.

You would need to move them outside like so:

$content_slug = ucfirst($page['content_slug']);
$content_title = ucfirst($page['content_title']);
$data = [
	'title' => "{$content_slug} ({$content_title}) ",
	'meta.description' => $description,
	'page' => $page,
];
return $app->render($template, $data);
}

 

Link to comment
Share on other sites

32 minutes ago, jarvis said:

Because of the semi-colon at the end of each declaration and those being declared inside $data.

You would need to move them outside like so:

$content_slug = ucfirst($page['content_slug']);
$content_title = ucfirst($page['content_title']);
$data = [
	'title' => "{$content_slug} ({$content_title}) ",
	'meta.description' => $description,
	'page' => $page,
];
return $app->render($template, $data);
}

 

That works now. Thank you very much!

Link to comment
Share on other sites

What exactly does 'crashing' mean to you/us?  Are you getting an error message?  Do you have error reporting enabled?

You are calling a function with two arguments.  What does the function do? It doesn't appear to return anything so why do you not use the ucfirst function on the 2 args before you use them in the function calll?  That is what I would do.  Or I would use the function on each of the args in the call.

Show us this code that is 'crashing' your hole(?) website.

Link to comment
Share on other sites

 breadcrumb_add('Page', ucfirst($page['content_slug']));

The first argument I simply made a change to.  The second arg I added the function to the var you were passing into the function.  Pretty simple, huh?  Of course I am assuming that your var is actually a string.  Correct?

Link to comment
Share on other sites

8 hours ago, ginerjm said:
 breadcrumb_add('Page', ucfirst($page['content_slug']));

The first argument I simply made a change to.  The second arg I added the function to the var you were passing into the function.  Pretty simple, huh?  Of course I am assuming that your var is actually a string.  Correct?

Now it works. Thank you very much!

Link to comment
Share on other sites

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.

 Share

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