PHP _construct()函数讲解

作者:php参考手册 时间:2023-06-14 16:56:43 

PHP _construct() 函数

实例

函数创建一个新的 SimpleXMLElement 对象,然后输出 body 节点的内容:


<?php
$note=<<<XML
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
XML;
$xml=new SimpleXMLElement($note);
echo $xml->body;
?>

[运行实例&raquo;](/try/showphp.php?filename=demo_func_simplexml_construct)

定义和用法

_construct() 函数创建一个新的 SimpleXMLElement 对象。

语法


_construct( _data,options,data_is_url,ns,is_prefix_ );

PHP _construct()函数讲解

PHP _construct()函数讲解

假设我们有如下的 XML 文件,"note.xml":


<?xml version="1.0" encoding="ISO-8859-1"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

实例 1

从 URL 中创建一个 SimpleXMLElement 对象:


<?php
$xml=new SimpleXMLElement("note.xml",NULL,TRUE);
echo $xml->asXML();
?>
标签:php,construct(),函数
0
投稿

猜你喜欢

  • 网页设计者应当注意九大要点

    2007-08-10 13:30:00
  • CSS入门了解CSS的伪类

    2007-10-24 19:36:00
  • 中文字体在 CSS 中的写法

    2009-11-24 13:21:00
  • 前端开发中的一些用户体验细节

    2010-10-19 12:23:00
  • Ethnique公司logo设计过程和思路

    2009-09-19 17:04:00
  • ASP中的Debug类--VBScript

    2008-10-24 09:38:00
  • Oracle PL/SQL入门慨述

    2010-07-18 12:57:00
  • 用asp实现读取文件的最后一行的代码

    2011-03-08 10:55:00
  • 为导入文件加上时间戳标记的两种方法

    2009-01-07 14:14:00
  • 什么是JSON及JSON的结构

    2008-06-15 07:16:00
  • SQL Server数据库查询优化的常用方法总结

    2008-12-10 14:43:00
  • ASP连接SQL2005数据库连接代码

    2011-03-25 10:44:00
  • MySQL 语言参考

    2007-11-21 20:37:00
  • JavaScript 全半角转换

    2010-02-04 17:14:00
  • 可能被你忽略的 JavaScript 代码陷阱

    2009-12-26 18:16:00
  • 土豆网前端概况

    2008-01-24 12:06:00
  • 微型设计专用工具Dorado

    2011-01-06 12:23:00
  • 提高MySQL数据库查询效率的三个实用技巧

    2008-12-03 16:40:00
  • 简易CSS相册源代码

    2008-04-18 12:28:00
  • 浅说相册图片详情页面中大图的浏览方式

    2009-02-01 18:34:00
  • asp之家 网络编程 m.aspxhome.com