{"id":76,"date":"2023-05-06T03:11:11","date_gmt":"2023-05-06T03:11:11","guid":{"rendered":"https:\/\/itnotes.apjsoftwares.com\/?p=76"},"modified":"2023-05-06T03:11:12","modified_gmt":"2023-05-06T03:11:12","slug":"what-is-a-strings-in-php-explain-string-functions-with-example","status":"publish","type":"post","link":"https:\/\/itnotes.apjsoftwares.in\/index.php\/2023\/05\/06\/what-is-a-strings-in-php-explain-string-functions-with-example\/","title":{"rendered":"\u00a0What is a strings in PHP explain string functions with example."},"content":{"rendered":"\n<p>PHP string is a sequence of characters i.e., used to store and manipulate text. PHP supports only 256-character sets and so it does not offer native Unicode support. There are 4 ways to specify a string literal in PHP.<\/p>\n\n\n\n<p>We can create a string in PHP by enclosing the text in a single-quote. It is the easiest way to specify strings in PHP.<\/p>\n\n\n\n<p>For specifying a literal single quote, escape it with a backslash (\\) and to specify a literal backslash (\\) use double backslash (\\\\). All the other instances with backslash such as \\r or \\n, will be output the same as they specified instead of having any special meaning.<\/p>\n\n\n\n<p><strong>Example<\/strong><\/p>\n\n\n\n<p>&lt;?php&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$str=&#8217;Hello text within single quote&#8217;;&nbsp;&nbsp;<\/p>\n\n\n\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $str;&nbsp;&nbsp;<\/p>\n\n\n\n<p>?&gt;&nbsp;<\/p>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<p>Hello text within single quote<\/p>\n\n\n\n<p><strong>String Function Examples<\/strong><\/p>\n\n\n\n<p><strong>strtolower() function<\/strong><\/p>\n\n\n\n<p>The strtolower() function returns a string in lowercase letters.<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<p>string strtolower ( string $string )&nbsp;&nbsp;<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<p>&lt;?php&nbsp;&nbsp;<\/p>\n\n\n\n<p>$str=&#8221;My name is Parmeshwar&#8221;;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$str=strtolower($str);&nbsp;&nbsp;<\/p>\n\n\n\n<p>echo $str;&nbsp;&nbsp;<\/p>\n\n\n\n<p>?&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>my name is parmeshwar<\/p>\n\n\n\n<p><strong>strtoupper() function<\/strong><\/p>\n\n\n\n<p>The strtoupper() function returns a string in uppercase letter.<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<p>string strtoupper ( string $string )&nbsp;&nbsp;<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<p>&lt;?php&nbsp;&nbsp;<\/p>\n\n\n\n<p>$str=&#8221;My name is Parmeshwar&#8221;;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$str=strtoupper($str);&nbsp;&nbsp;<\/p>\n\n\n\n<p>echo $str;&nbsp;&nbsp;<\/p>\n\n\n\n<p>?&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>MY NAME IS PARMESWAR<\/p>\n\n\n\n<p><strong>ucfirst() function<\/strong><\/p>\n\n\n\n<p>The ucfirst() function returns a string converting first character into uppercase. It doesn&#8217;t change the case of other characters.<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<p>string ucfirst ( string $str )&nbsp;&nbsp;<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<p>&lt;?php&nbsp;&nbsp;<\/p>\n\n\n\n<p>$str=&#8221;my name is PARMESWAR&#8221;;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$str=ucfirst($str);&nbsp;&nbsp;<\/p>\n\n\n\n<p>echo $str;&nbsp;&nbsp;<\/p>\n\n\n\n<p>?&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>My name is PARMESWAR<\/p>\n\n\n\n<p><strong>lcfirst() function<\/strong><\/p>\n\n\n\n<p>The lcfirst() function returns a string converting the first character into lowercase. It doesn&#8217;t change the case of other characters.<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<p>string lcfirst ( string $str )&nbsp;&nbsp;<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<p>&lt;?php&nbsp;&nbsp;<\/p>\n\n\n\n<p>$str=&#8221;MY name IS Parmeshwar&#8221;;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$str=lcfirst($str);&nbsp;&nbsp;<\/p>\n\n\n\n<p>echo $str;&nbsp;&nbsp;<\/p>\n\n\n\n<p>?&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>mY name IS Parmeshwar<\/p>\n\n\n\n<p><strong>ucwords() function<\/strong><\/p>\n\n\n\n<p>The ucwords() function returns a string converting the first character of each word into uppercase.<\/p>\n\n\n\n<p>Syntax<\/p>\n\n\n\n<p>string ucwords ( string $str )&nbsp;&nbsp;<\/p>\n\n\n\n<p>Example<\/p>\n\n\n\n<p>&lt;?php&nbsp;&nbsp;<\/p>\n\n\n\n<p>$str=&#8221;my name is Parmeshwar kuril&#8221;;&nbsp;&nbsp;<\/p>\n\n\n\n<p>$str=ucwords($str);&nbsp;&nbsp;<\/p>\n\n\n\n<p>echo $str;&nbsp;&nbsp;<\/p>\n\n\n\n<p>?&gt;&nbsp;&nbsp;<\/p>\n\n\n\n<p>Output:<\/p>\n\n\n\n<p>My Name Is Parmeshwar Kuril<\/p>\n","protected":false},"excerpt":{"rendered":"<p>PHP string is a sequence of characters i.e., used to store and manipulate text. PHP&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/76"}],"collection":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":1,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":77,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/posts\/76\/revisions\/77"}],"wp:attachment":[{"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itnotes.apjsoftwares.in\/index.php\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}