PHP in Hindi Strings




PHP मे String Characters का एक Sequence है जो कि Text को Stored और हेर फेर करने के लिए उपयोग किया जाता है. Strings को किसी Person, Place या किसी अन्य Character पर आधारित Value, Name, आदि को Stored करने के लिए उपयोग करते है. PHP मे एक Strings को Single या Double Quotation Marks के भीतर Text को Attachment करके बनाया जाता है.

PHP मे String को Specify करने के चार तरीके है.

  • single quoted

  • double quoted

  • heredoc syntax

  • newdoc syntax

Single Quoted String

हम एक Single Quote में Text संलग्न करके PHP में स्ट्रिंग बना सकते हैं. यह PHP में String Specify करने का सबसे आसान तरीका है.

For Example

<!DOCTYPE html>
<html>   
   <head>
      <title>Single Quoted String Example</title>
   </head>   
   <body>
   <body>      
      <?php
         $str='Hello text within single quote';  
         echo $str;     
      ?>      
   </body>
</html>

Output

Hello text within single quote

Double Quoted String

PHP में, हम String को Double Quote के भीतर Text को Attached करके भी Specify कर सकते हैं. लेकिन Escape Sequences और Variables को Double Quote PHP String का उपयोग करके व्याख्या की जाएगी.

For Example

<!DOCTYPE html>
<html>   
   <head>
      <title>Double Quoted String Example</title>
   </head>   
   <body>     
      <?php
         $str1="Hello text   
         multiple line  
         text within double quoted string";  
         $str2="Using double \"quote\" with backslash inside double quoted string";  
         $str3="Using escape sequences \n in double quoted string";  
         echo "$str1 <br/> $str2 <br/> $str3";         
      ?>     
   </body>
</html>

Output

Hello text multiple line text within double quoted string
Using double "quote" with backslash inside double quoted string
Using escape sequences in double quoted string