Home  >  Article  >  Backend Development  >  How to use var_export in PHP

How to use var_export in PHP

不言
不言Original
2018-07-14 17:01:2410919browse

This article mainly introduces the use of var_export in PHP. It has certain reference value. Now I share it with you. Friends in need can refer to it.

var_export can convert an array into a string

Unlike var_dump, var_export does not output the type of data and character size, etc., but simply splices the key and value of the array into A string

<?php

$arr = [
&#39;key1&#39;=>&#39;val1&#39;,
&#39;key2&#39;=>&#39;val2&#39;,
&#39;key3&#39;=>&#39;val3&#39;,
&#39;key4&#39;=>&#39;val4&#39;,
&#39;key5&#39;=>&#39;val5&#39;
];

$str = var_export($arr,true);
echo $str;//结果 array ( &#39;key1&#39; => &#39;val1&#39;, &#39;key2&#39; => &#39;val2&#39;, &#39;key3&#39; => &#39;val3&#39;, &#39;key4&#39; => &#39;val4&#39;, &#39;key5&#39; => &#39;val5&#39;, )
?>
Recommended related articles: ​  
1. Analysis of the difference between var_export and var_dump in php
Related video recommendations:
2.Dugu Jiujian (4)_PHP Video tutorial

The above is the entire content of this article. I hope it will be helpful to everyone’s learning. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

How to get the file extension through PHP

The above is the detailed content of How to use var_export in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn