php strings
Strings character का sequence यानि की समूह (group) है||
string declaration
string तीन तरीके से declare कर सकते है||
- single quoted
- double quoted
- doc syntax
- nowdoc => यह single quoted की तरह काम करता है||
- heredoc => यह double quoted की तरह काम करता है||
Single quoted
single quoted में, string को single quoted में declared किया जाता है| single quoted character: ‘ ‘
<?php
$string = 'Hello this is my first single quoted strings';
echo $string;
?>
output
अगर हम single quoted string में another single quoted को add करना चाहते है तो back slash character के साथ add कर सकते है|
<?php
$string = 'Hello this is my first strings it\'s very good';
echo $string;
?>
output
Double quoted
double quoted में, string को double quoted में declared किया जाता है| double quoted character: ” “
<?php
$string = "Hello this is my first double quoted strings";
echo $string;
?>
output
single quoted के मुकाबले double quoted में कई सारे escape sequence है|
| Escape sequence | Description |
| \” | double quoted |
| \n | line break |
| \t | tab space |
| \r | carriage return |
| \\ | backslash |
| \$ | dollar sign |
Doc syntax
Doc syntax में string को अलग way में declared किया जा सकता है जिसमे दो प्रकार है 1) heredoc 2) nowdoc और वह single और double quoted की तरह काम करते है||
Doc syntax <<<IDENTIFIERTOKEN characters के साथ start होता है| और IDENTIFIERTOKEN के साथ close होता है|
और उसके बाद identifier token को <<< के साथ एक ही line में single और double qouted में लिखा जाता है|
syntax:
$data = <<<IDENTIFIERTOKEN
IDENTIFIERTOKEN;
Nowdoc
Nowdoc यह similar single quoted के तरह work करता है|
<?php
$string =<<<'STRING'
welcome to RjtechyG <br>
it is very helful for the beginners<br>
it is also have "hindi" contant<br>
this is nowdoc synax.
STRING;
echo $string;
?>
output
it is very helful for the beginners
it is also have “hindi” contant
this is nowdoc synax.
heredoc
heredoc यह similar double quoted के तरह work करता है| heredoc में token को double quoted में लिखने की जरुरत नहीं होती है|
<?php
$string =<<<STRING
Welcome to RjtechyG
it is very helpful for the beginners
it also has "Hindi" content
this is heredoc syntax.
STRING;
echo $string;
?>
output
it is very helpful for the beginners
it also has “Hindi” content
this is heredoc syntax.






