Skip to content

Commit 34dbb65

Browse files
committed
Create 08_string_functions.php
PHP String Functions. link: https://www.w3schools.com/php/php_ref_string.asp
1 parent c931c7f commit 34dbb65

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

08_string_functions.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
/**
3+
* Eng: The PHP string functions are part of the PHP core. No installation is required to use these functions.
4+
* more on the link: https://www.w3schools.com/php/php_ref_string.asp
5+
*
6+
* Pt: As funções de string do PHP fazem parte do núcleo do PHP. Nenhuma instalação é necessária para usar essas funções.
7+
* mais no link: https://www.w3schools.com/php/php_ref_string.asp
8+
*/
9+
10+
$string = 'Eng: Hello World !!! || Pt: Ola Mundo !!!';
11+
12+
//Eng: get the length of a string || Pt: obter o comprimento de uma string
13+
echo strlen($string);
14+
echo '<br>';
15+
16+
17+
//Eng: find the pasition of the first occurence of a substring in a string || Pt: encontre a passagem da primeira ocorrência de uma substring em uma string
18+
echo strpos($string, 'o');
19+
echo '<br>';
20+
21+
//Eng: find the positon of the last occurence of a substring in a string || Pt: encontre a posição da última ocorrência de uma substring em uma string
22+
echo strrpos($string, 'o');
23+
echo '<br>';
24+
25+
//Eng: Reverse a string || Pt: Inverter uma string
26+
echo strrev($string);
27+
echo '<br>';
28+
29+
//Eng: covert all characters to lowercase || Pt: converter todos os caracteres para minúsculos
30+
echo strtolower($string);
31+
echo '<br>';
32+
33+
//Eng: covert all characters to uppercase || Pt: converta todos os caracteres para maiúsculos
34+
echo strtoupper($string);
35+
echo '<br>';
36+
37+
//Eng: uppercase the first character of each word || Pt: maiúsculo o primeiro caractere de cada palavra
38+
echo ucwords($string);
39+
echo '<br>';
40+
41+
42+
//Eng: uppercase the first character of each word
43+
echo str_replace('World', 'Everyone', $string);
44+
echo '<br>';
45+
46+
47+
48+
/* more on the link: https://www.w3schools.com/php/php_ref_string.asp
49+
* /
50+
51+
52+
53+
?>

0 commit comments

Comments
 (0)