Php variables
Hello. I have a question about Php.
<?php
$p = \"starcraft\";
echo(\"$p\");
?>
The code above will output "starcraft" on my page. My question is, is there a way to make the first letter caps? On the page it it would appear "Starcraft" instead of "starcraft", but the value would still be $p = "starcraft".
Abhishek Reddy posted this at 21:04 — 24th December 2002.
He has: 3,348 posts
Joined: Jul 2001
ucwords
zollet posted this at 22:25 — 24th December 2002.
He has: 1,016 posts
Joined: May 2002
There are actually 2 options depending on your needs...
<?php
$p = \"hello world\";
echo ucfirst($p); // This will print \"Hello world\" (UC first char only)
echo ucwords($p); // This will print \"Hello World\" (UC first char of all words)
?>
Era posted this at 01:04 — 28th December 2002.
They have: 18 posts
Joined: Nov 2002
Thank you for your help.
nike_guy_man posted this at 02:02 — 28th December 2002.
They have: 840 posts
Joined: Sep 2000
Well, I guess you really DO learn something new every day
Thanks for the tip
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.