From the course: PHP for Web Designers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Using functions to manipulate values

Using functions to manipulate values - PHP Tutorial

From the course: PHP for Web Designers

Start my 1-month free trial

Using functions to manipulate values

Often, the values stored in the database or submitted through an online form, aren't in the right format. PHP provides a huge number of built in functions that allow you to manipulate string values. As a simple example, let's use a function to convert a string to uppercase. In the file that I've got open, above the doc type, I've created a variable called city and I've assigned it the value, London. And in the HTML down below, I've got 3 paragraphs with PHP blocks that use echo to display the value of city. And in this second paragraph, I want to convert the value of city. To uppercase. I'm going to do that using a built in PHP function that has a rather unpronounceable name, str2upper. It makes a bit more sense when you realize that the str at the beginning stands for string. So it's string to upper, or string to upper case. I'll call it string to upper to make it easier to pronounce. So to convert city to upper case, I need to pass city as an argument to string to upper. The way I…

Contents