Translate

2013年9月18日 星期三

php 好用但不常用的function

addslashes($str);

ex 

<?php
$str 
"Is your name O'reilly?";// output: Is your name O\'reilly?echo addslashes($str);?>


simplexml_load_string($str)

<?php
$string 
= <<<XML<?xml version='1.0'?>
<document>
 <title>Forty What?</title>
 <from>Joe</from>
 <to>Jane</to>
 <body>
  I know that's the answer -- but what's the question?
 </body>
</document>
XML;
$xml simplexml_load_string($string);
print_r($xml);?>
 
$json = json_encode($xml);
$array = json_decode($json,TRUE); 
 

沒有留言:

張貼留言