jacob1986 Posted December 6, 2015 Share Posted December 6, 2015 I have to write small segment of PHP code to print the word(s) 'Hello, World!' in uppercase letters, I have thus far wrote a small section of code that prints the output 'Hello, World!'. But, I'm completely stuck on how to make the letters all uppercase?!?? Moreover; that strtoupper goes somewhere in there right? <?php class TextFunctions { public static $string = 'Hello, World!'; static public function strtoupper() { }}echo TextFunctions::$string; ?> Quote Link to comment https://forums.phpfreaks.com/topic/299659-php-method-class-uppercase/ Share on other sites More sharing options...
requinix Posted December 7, 2015 Share Posted December 7, 2015 strtoupper() is a function that already exists. You don't make it yourself. It takes a string as an argument and returns a string. What it returns is uppercased. echo strtoupper(TextFunctions::$string); Quote Link to comment https://forums.phpfreaks.com/topic/299659-php-method-class-uppercase/#findComment-1527613 Share on other sites More sharing options...
maxxd Posted December 7, 2015 Share Posted December 7, 2015 You can also do this via CSS with text_transform: uppercase. Quote Link to comment https://forums.phpfreaks.com/topic/299659-php-method-class-uppercase/#findComment-1527625 Share on other sites More sharing options...
Barand Posted December 7, 2015 Share Posted December 7, 2015 That will only affect the display in the form, not convert. Lowercase characters are posted EG <?php if ($_SERVER['REQUEST_METHOD']=='POST') echo "Posted value : {$_POST['test']}"; //--> Hello World ?> <form method='post'> <input type='text' name='test' style='text-transform:uppercase' value='Hello World'> <input type='submit' name='btnsub' value='Submit'> </form> Quote Link to comment https://forums.phpfreaks.com/topic/299659-php-method-class-uppercase/#findComment-1527637 Share on other sites More sharing options...
maxxd Posted December 7, 2015 Share Posted December 7, 2015 Barand - absolutely, but if using CSS to modify the display is appropriate and allowed for the assignment, it's another viable way to do it. Quote Link to comment https://forums.phpfreaks.com/topic/299659-php-method-class-uppercase/#findComment-1527641 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.