PHP stdClass In Hindi | stdClass In PHP
PHP Error Control Operator In Hindi | Error Control In PHP
PHP Program to check whether number is Palindrome or not | PHP Find Palindrome Number
PHP filter_var() Function In Hindi | filter_var() In PHP In Hindi
Bubble Sort in PHP With Example | How Bubble Sort Works in PHP
grep Command in Linux : What is grep Command ?
Variables In Snowflake In Hindi | Snowflake Variables In Hindi
If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
Normally PHP में जब हम variable को print / echo कराते हैं तो उसकी value print होती है। लेकिन अगर आप उस variable में stored value को actual PHP form में देखना चाहते हैं तो var_export()
function का use कर सकते हैं।
●●●
var_export()
function दिए गए variable की structured information return करता है जो कि actual PHP code होता है। यह var_dump() function के जैसे ही है बस difference इतना है कि var_dump() variable में stored value के बारे में information देता है जो PHP code नहीं होता है।
var_export(mixed $value, bool $return = false): ?string
$value | required
: यह वो variable है जिसे export करना है।
$return | optional
: by default false
set होता है , लेकिन अगर आपने true set किया तो यह सिर्फ variable को represent करेगा मतलब फिर आपको echo
use करना पड़ेगा। और false
के साथ echo
के बिना output print करेगा।
●●●
$a = array (1, 2, array ("a", "b", "c"));
var_export($a);
output
array ( 0 => 1, 1 => 2, 2 => array ( 0 => 'a', 1 => 'b', 2 => 'c', ), )
अब अगर आप true
pass करेंगे तो output देखने के लिए आपको echo
use करना पड़ेगा। हालाँकि output same रहेगा।
$a = array (1, 2, array ("a", "b", "c"));
echo var_export($a, true);
●●●
इसी तरह से stdClass Class को भी export कर सकते हैं।
$obj = new stdClass;
$obj->title = 'Learn programming in hindi';
$obj->website = 'https://learnhindituts.com';
var_export($obj);
Output
(object) array( 'title' => 'Learn programming in hindi', 'website' => 'https://learnhindituts.com', )
और कुछ इसी तरह से normal Class object को भी export कर सकते हैं।
class A {
public $title;
public $website;
}
$a = new A();
$a->title = "Learn programming in hindi";
$a->website = "https://learnhindituts.com";
var_export($a);
Output
\A::__set_state(array( 'title' => 'Learn programming in hindi', 'website' => 'https://learnhindituts.com', ))
●●●
I hope , अब आप PHP में var_export()
function के बारे में अच्छे से समझ गए होंगे ।
Loading ...
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook