Skip to content

Commit df96131

Browse files
032-String processing in PHP (str_replace, substr, strlen)
1 parent 3ac55f1 commit df96131

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
$domain = "www.phpfullstack.com.br";
3+
echo "{$domain}\n";
4+
echo str_replace("www.", "https://", $domain) . "\n";
5+
echo "{$domain}\n";
6+
7+
$domain = str_replace("www.", "https://", $domain);
8+
$protocol = substr($domain, 0, 8);
9+
echo $protocol === "https://" ? "It's safe\n" : "It's not safe\n";
10+
11+
$region = substr($domain, -3);
12+
echo "region = $region\n";
13+
echo $region === "com" ? "International website\n" : "Local website\n";
14+
15+
var_dump($domain);
16+
var_dump(substr($domain, 8, -7));
17+
var_dump(strlen($domain));

0 commit comments

Comments
 (0)