Usage and cases of case conversion function in php

墨辰丷
Release: 2023-03-26 09:08:02
Original
1685 people have browsed it

strtoupper() function converts the string to uppercase and strtolower function: This function converts all characters of the incoming string parameter to lowercase and puts the string back in small definite form. This article will share with you the usage of PHP case conversion functions (strtolower, strtoupper). Friends who need it can refer to

1 to convert strings into lowercase

strtolower function: This function converts all characters of the incoming string parameter to lowercase and puts them back into the string in decimal form.

Example:

<?php
  $str = "I want To FLY";
  $str = strtolower($str);
  echo $str;
//by www.jb51.net
?>
Copy after login

Output:

i want to fly
Copy after login

2, Convert characters to uppercase

strtoupper function: The function of this function is opposite to the strtolower function. It converts all the characters of the incoming character parameters into uppercase and returns this in uppercase. string.

Usage is the same as strtolower().

Here are two more useful functions.

3, Convert the first character of the string to uppercase

ucfirst function: The function of this function is to change the first character of the string to uppercase. This function Returns a string whose first character is uppercase.

Usage is similar to strtolower() function.

4, Convert the first character of each word in the string to uppercase

ucwords: This function converts the first character of each word in the incoming string into uppercase into uppercase. For example, "hello world", after processing by this function, "Hello Word" will be returned.

Usage is similar to strtolower().

Let’s focus on the most commonly used functions

When writing PHP programs, you often need to capitalize some strings Conversion, here are some of the most commonly used functions

strtolower() //Convert the string to lowercase form

strtoupper() //Convert the string to uppercase form

ucfirst() //Convert the first character of the string to uppercase

ucwords() //Convert the first letter of each word in the string For uppercase form

Related recommendations:

PHP case sensitivity issue

php case conversion function ( strtolower, strtoupper) usage introduction

PHP case problem: function names and class names are not distinguished, variable names are distinguished_PHP tutorial

The above is the detailed content of Usage and cases of case conversion function in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template