当前位置: 首页>>代码示例>>PHP>>正文


PHP simplexml_load_string函数代码示例

本文整理汇总了PHP中simplexml_load_string函数的典型用法代码示例。如果您正苦于以下问题:PHP simplexml_load_string函数的具体用法?PHP simplexml_load_string怎么用?PHP simplexml_load_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了simplexml_load_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: responseMsg

 public function responseMsg()
 {
     //get post data, May be due to the different environments
     $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
     //extract post data
     if (!empty($postStr)) {
         /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,
            the best way is to check the validity of xml by yourself */
         libxml_disable_entity_loader(true);
         $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
         $fromUsername = $postObj->FromUserName;
         $toUsername = $postObj->ToUserName;
         $keyword = trim($postObj->Content);
         $time = time();
         $textTpl = "<xml>\n\t\t\t\t\t\t\t<ToUserName><![CDATA[%s]]></ToUserName>\n\t\t\t\t\t\t\t<FromUserName><![CDATA[%s]]></FromUserName>\n\t\t\t\t\t\t\t<CreateTime>%s</CreateTime>\n\t\t\t\t\t\t\t<MsgType><![CDATA[%s]]></MsgType>\n\t\t\t\t\t\t\t<Content><![CDATA[%s]]></Content>\n\t\t\t\t\t\t\t<FuncFlag>0</FuncFlag>\n\t\t\t\t\t\t\t</xml>";
         if (!empty($keyword)) {
             $msgType = "text";
             $contentStr = "Welcome to wechat world!";
             $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
             echo $resultStr;
         } else {
             echo "Input something...";
         }
     } else {
         echo "";
         exit;
     }
 }
开发者ID:sirxun,项目名称:uploadImag,代码行数:28,代码来源:wx_sample.php

示例2: toXml

 public static function toXml($data, $rootNodeName = 'data', $xml = null)
 {
     // turn off compatibility mode as simple xml throws a wobbly if you don't.
     if (ini_get('zend.ze1_compatibility_mode') == 1) {
         ini_set('zend.ze1_compatibility_mode', 0);
     }
     if ($xml == null) {
         $xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><{$rootNodeName} />");
     }
     // loop through the data passed in.
     foreach ($data as $key => $value) {
         // no numeric keys in our xml please!
         if (is_numeric($key)) {
             // make string key...
             $key = "child_" . (string) $key;
         }
         // replace anything not alpha numeric
         $key = preg_replace('/[^a-z]/i', '', $key);
         // if there is another array found recrusively call this function
         if (is_array($value)) {
             $node = $xml->addChild($key);
             // recrusive call.
             ArrayToXML::toXml($value, $rootNodeName, $node);
         } else {
             // add single node.
             $value = htmlentities($value);
             $xml->addChild($key, $value);
         }
     }
     // pass back as string. or simple xml object if you want!
     return $xml->asXML();
 }
开发者ID:beingsane,项目名称:Joomla-REST-API,代码行数:32,代码来源:classes.php

示例3: parseDataFromResponse

 /**
  * 解析从ListMultipartUpload接口的返回数据
  *
  * @return ListMultipartUploadInfo
  */
 protected function parseDataFromResponse()
 {
     $content = $this->rawResponse->body;
     $xml = simplexml_load_string($content);
     $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : "";
     $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : "";
     $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : "";
     $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType);
     $uploadIdMarker = isset($xml->UploadIdMarker) ? strval($xml->UploadIdMarker) : "";
     $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : "";
     $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType);
     $nextUploadIdMarker = isset($xml->NextUploadIdMarker) ? strval($xml->NextUploadIdMarker) : "";
     $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : "";
     $delimiter = OssUtil::decodeKey($delimiter, $encodingType);
     $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : "";
     $prefix = OssUtil::decodeKey($prefix, $encodingType);
     $maxUploads = isset($xml->MaxUploads) ? intval($xml->MaxUploads) : 0;
     $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : "";
     $listUpload = array();
     if (isset($xml->Upload)) {
         foreach ($xml->Upload as $upload) {
             $key = isset($upload->Key) ? strval($upload->Key) : "";
             $key = OssUtil::decodeKey($key, $encodingType);
             $uploadId = isset($upload->UploadId) ? strval($upload->UploadId) : "";
             $initiated = isset($upload->Initiated) ? strval($upload->Initiated) : "";
             $listUpload[] = new UploadInfo($key, $uploadId, $initiated);
         }
     }
     return new ListMultipartUploadInfo($bucket, $keyMarker, $uploadIdMarker, $nextKeyMarker, $nextUploadIdMarker, $delimiter, $prefix, $maxUploads, $isTruncated, $listUpload);
 }
开发者ID:rockuw,项目名称:aliyun-oss-php-sdk,代码行数:35,代码来源:ListMultipartUploadResult.php

示例4: start

 private function start($parser, $name, $attrs)
 {
     $name = str_replace(':', '', $name);
     if ($this->depth == 1) {
         $this->node = $this->handler = simplexml_load_string("<{$name}></{$name}>", 'SimpleXMLElement', LIBXML_COMPACT | LIBXML_PARSEHUGE);
     } elseif ($this->depth > 1) {
         if ($this->raw != false) {
             $this->handler[0] .= '<' . $name . ' ';
             if ($this->raw <= $this->depth) {
                 foreach ($attrs as $name => $value) {
                     $this->handler[0] .= $name . "='" . $value . "' ";
                 }
             }
             $this->handler[0] .= '>';
         } else {
             $this->handler = $this->handler->addChild($name);
         }
     }
     if (isset($this->handler) && $this->raw == false) {
         foreach ($attrs as $name => $value) {
             if ('xmlns:' === substr($name, 0, 6)) {
                 $name = 'xmlns:' . $name;
             }
             if ($value === 'http://www.w3.org/1999/xhtml') {
                 $this->raw = $this->depth;
             }
             $this->handler->addAttribute($name, $value);
         }
     }
     $this->depth++;
 }
开发者ID:Hywan,项目名称:moxl,代码行数:31,代码来源:Parser.php

示例5: load

 /**
  * Returns array of simple xml objects, where key is a handle name
  *
  * @return SimpleXmlElement[]
  * @throws RuntimeException in case of load error (malformed xml, etc)
  */
 public function load()
 {
     $this->validate();
     $original = libxml_use_internal_errors(true);
     $simpleXmlElement = simplexml_load_file($this->filePath);
     $errors = libxml_get_errors();
     libxml_clear_errors();
     libxml_use_internal_errors($original);
     if ($simpleXmlElement === false) {
         $messages = array();
         foreach ($errors as $error) {
             $messages[] = sprintf('%s, line %s, column %s', trim($error->message), $error->line, $error->column);
         }
         throw new RuntimeException(sprintf('File "%s" has a malformed xml structure: %s', $this->filePath, PHP_EOL . implode(PHP_EOL, $messages)));
     }
     $stringXml = array();
     // First convert all elements to string,
     // as in xml file can be multiple string with the same handle names
     foreach ($simpleXmlElement->children() as $key => $element) {
         if (!isset($stringXml[$key])) {
             $stringXml[$key] = '';
         }
         foreach ($element->children() as $child) {
             $stringXml[$key] .= $child->asXml();
         }
     }
     $result = array();
     foreach ($stringXml as $key => $xml) {
         $result[$key] = simplexml_load_string(sprintf('<%1$s>%2$s</%1$s>', $key, $xml));
     }
     return $result;
 }
开发者ID:albertobraschi,项目名称:EcomDev_LayoutCompiler,代码行数:38,代码来源:File.php

示例6: testXmlValidates

 public function testXmlValidates()
 {
     $f = new XmlFormatter();
     $line = $f->format(array('message' => 'foo', 'priority' => 42));
     $sxml = @simplexml_load_string($line);
     $this->assertInstanceOf('SimpleXMLElement', $sxml, 'Formatted XML is invalid');
 }
开发者ID:robertodormepoco,项目名称:zf2,代码行数:7,代码来源:XmlTest.php

示例7: checkXml

 /**
  * Check the given xml
  *
  * @param string $xml
  *
  * @return null
  *
  * @throws InvalidXmlException
  */
 public function checkXml($xml)
 {
     $output = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOERROR);
     if (false === $output) {
         throw new InvalidXMLException();
     }
 }
开发者ID:jarocks,项目名称:MagentoConnectorBundle,代码行数:16,代码来源:XmlChecker.php

示例8: __construct

 private function __construct($objectId, $mySide)
 {
     $this->mySide = $mySide;
     $this->object = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $objectId);
     if (!$this->object || !$this->object instanceof \steam_container) {
         throw new Exception("Wave side not found.");
     }
     //$controlObject = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $this->object->get_path() . "/control.xml");
     if (isset($controlObject) && $controlObject instanceof \steam_document) {
         $xmlStr = $controlObject->get_content();
         $xml = simplexml_load_string($xmlStr);
         $children = $xml->children();
         foreach ($children as $child) {
             if ($child->getName() == "OBJ_DESC") {
                 $this->object->set_attribute(OBJ_DESC, $child->asXML());
             } else {
                 if ($child->getName() == "steamweb_type") {
                     $this->object->set_attribute("WAVEPAGE_TYPE", $child->asXML());
                 } else {
                     if ($child->getName() == "steamweb_type_config") {
                         $subChildren = $child->children();
                         $map = XmlHelper::xml_to_array($subChildren[0]);
                         $this->object->set_attribute("WAVEPAGE_TYPE_CONFIG", $map[0]);
                     } else {
                         if ($child->getName() == "steamweb_module_ssp") {
                             $subChildren = $child->children();
                             $this->object->set_attribute("WAVEPAGE_MODULE_SSP_ALBUM_NO", $subChildren[0]->asXML());
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:rolwi,项目名称:koala,代码行数:34,代码来源:WavePage.class.php

示例9: getInstance

 /**
  * Returns an instance of KeyInfo object based on the input KeyInfo XML block
  *
  * @param string $xmlData The KeyInfo XML Block
  * @return Zend_InfoCard_Xml_KeyInfo_Abstract
  * @throws Zend_InfoCard_Xml_Exception
  */
 public static function getInstance($xmlData)
 {
     if ($xmlData instanceof Zend_InfoCard_Xml_Element) {
         $strXmlData = $xmlData->asXML();
     } else {
         if (is_string($xmlData)) {
             $strXmlData = $xmlData;
         } else {
             throw new Zend_InfoCard_Xml_Exception("Invalid Data provided to create instance");
         }
     }
     $sxe = simplexml_load_string($strXmlData);
     $namespaces = $sxe->getDocNameSpaces();
     if (!empty($namespaces)) {
         foreach ($sxe->getDocNameSpaces() as $namespace) {
             switch ($namespace) {
                 case 'http://www.w3.org/2000/09/xmldsig#':
                     include_once 'Zend/InfoCard/Xml/KeyInfo/XmlDSig.php';
                     return simplexml_load_string($strXmlData, 'Zend_InfoCard_Xml_KeyInfo_XmlDSig');
                 default:
                     throw new Zend_InfoCard_Xml_Exception("Unknown KeyInfo Namespace provided");
                     // We are ignoring these lines, as XDebug reports each as a "non executed" line
                     // which breaks my coverage %
                     // @codeCoverageIgnoreStart
             }
         }
     }
     // @codeCoverageIgnoreEnd
     include_once 'Zend/InfoCard/Xml/KeyInfo/Default.php';
     return simplexml_load_string($strXmlData, 'Zend_InfoCard_Xml_KeyInfo_Default');
 }
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:38,代码来源:KeyInfo.php

示例10: browse

 public function browse($source, $from)
 {
     $source = strtolower($source);
     $index = $this->config[$source]['id'];
     $bases = $this->config['Global']['bases'];
     $removeRegex = $this->config[$source]['search_remove'];
     if (isset($removeRegex)) {
         $from = preg_replace($removeRegex, '', $from);
     }
     $params = array('index' => $index, 'query' => $from, 'base' => $bases);
     $answer = $this->httpService->get($this->cgiUrl, $params);
     $xml = simplexml_load_string($answer->getBody());
     $indexes = array();
     $count = 0;
     $next = null;
     foreach ($xml->{'result'} as $result) {
         $ids = array();
         foreach ($result->id as $id) {
             $ids[] = (string) $id;
         }
         $heading = $this->getDisplayText($source, (string) $result->display);
         if ($count < 10) {
             $indexes[] = array('heading' => $heading, 'ids' => $ids, 'count' => count($ids));
         } else {
             $next = (string) $result->sort;
         }
         $count++;
     }
     $result = array('items' => $indexes);
     if (isset($next)) {
         $result['nextQuery'] = array('source' => $source, 'from' => $next);
     }
     return $result;
 }
开发者ID:paulusova,项目名称:VuFind-2.x,代码行数:34,代码来源:Connector.php

示例11: getItemData

 protected function getItemData($item_id, $lang, $itemname = '', $type = 'items')
 {
     if ($item_id < 1) {
         return null;
     }
     $xml_link = 'http://lotro.allakhazam.com/cluster/item-xml.pl?lotritem=' . $item_id;
     $xml_data = $this->puf->fetch($xml_link);
     $xml = simplexml_load_string($xml_data);
     //filter baditems
     if (!isset($xml->display_html) or strlen($xml->display_html) < 5) {
         $item['baditem'] = true;
         return $item;
     }
     $item['link'] = 'http://lotro.allakhazam.com/db/item.html?lotritem=' . $item_id;
     $item['id'] = 0;
     # dont store this id, since its an allkhazam internal id
     $item['name'] = (string) $xml->item_name;
     $item['icon'] = (string) $xml->icon;
     $item['lang'] = $lang;
     $item['color'] = 'item' . $xml->quality;
     $item['html'] = (string) $xml->display_html;
     $item['html'] = $item['html'];
     //reposition allakhazam-credit-stuff
     $alla_credit = '<br><span class="akznotice">Item display is courtesy <a href="http://lotro.allakhazam.com/">lotro.allakhazam.com</a>.</span>';
     $item['html'] = str_replace($alla_credit, "", $item['html']) . $alla_credit;
     $item['html'] = str_replace('{ITEM_HTML}', $item['html'], file_get_contents($this->root_path . 'games/lotro/infotooltip/templates/lotro_popup.tpl'));
     return $item;
 }
开发者ID:ZerGabriel,项目名称:game-lotro,代码行数:28,代码来源:lotro_allakhazam.class.php

示例12: testNormalizeArray

    public function testNormalizeArray()
    {
        $client = new Client($this->getConfig());
        $rfl = new \ReflectionClass($client);
        $method = $rfl->getMethod('normalizeArray');
        $method->setAccessible(true);
        $xml = <<<EOF
<?xml version="1.0"?>
<root>
    <key>value</key>
    <empty></empty>
    <recursive>
        <key>value</key>
        <empty></empty>
    </recursive>
    <list>
        <item>
            <key>value</key>
        </item>
        <item>
            <key>value</key>
        </item>
    </list>
</root>
EOF;
        $array = (array) simplexml_load_string($xml);
        $array = $method->invoke($client, $array);
        $this->assertTrue(is_array($array));
        $this->assertCount(4, $array);
        $this->assertArrayHasKey('key', $array);
        $this->assertArrayHasKey('empty', $array);
        $this->assertArrayHasKey('recursive', $array);
        $this->assertArrayHasKey('list', $array);
        $this->assertSame('value', $array['key']);
        $this->assertNull($array['empty']);
        $this->assertTrue(is_array($array['recursive']));
        $this->assertTrue(is_array($array['list']));
        $this->assertFalse($array['recursive'] instanceof \SimpleXMLElement);
        $this->assertFalse($array['list'] instanceof \SimpleXMLElement);
        $recursive = $array['recursive'];
        $this->assertCount(2, $recursive);
        $this->assertArrayHasKey('key', $recursive);
        $this->assertArrayHasKey('empty', $recursive);
        $this->assertSame('value', $recursive['key']);
        $this->assertNull($recursive['empty']);
        $list = $array['list'];
        $this->assertCount(1, $list);
        $this->assertArrayHasKey('item', $list);
        $this->assertTrue(is_array($list['item']));
        $this->assertFalse($list['item'] instanceof \SimpleXMLElement);
        $this->assertCount(2, $list['item']);
        $this->assertArrayHasKey(0, $list['item']);
        $this->assertArrayHasKey(1, $list['item']);
        $this->assertTrue(is_array($list['item'][0]));
        $this->assertTrue(is_array($list['item'][1]));
        $this->assertArrayHasKey('key', $list['item'][0]);
        $this->assertArrayHasKey('key', $list['item'][1]);
        $this->assertSame('value', $list['item'][0]['key']);
        $this->assertSame('value', $list['item'][1]['key']);
    }
开发者ID:gordalina,项目名称:easypay-php,代码行数:60,代码来源:ClientTest.php

示例13: testTel

    /**
     * Test the JFormRuleTel::test method.
     */
    public function testTel()
    {
        $rule = new JFormRuleTel();
        $xml = simplexml_load_string('<form><field name="tel1" plan="NANP" />
			<field name="tel2" plan="ITU-T" /><field name="tel3" plan="EPP" />
			<field name="tel4" /></form>');
        // Test fail conditions NANP.
        $this->assertThat($rule->test($xml->field[0], 'bogus'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[0], '123451234512'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[0], 'anything_5555555555'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[0], '5555555555_anything'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        // Test fail conditions ITU-T.
        $this->assertThat($rule->test($xml->field[1], 'bogus'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[1], '123451234512'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[1], 'anything_5555555555'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[1], '5555555555_anything'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[1], '1 2 3 4 5 6 '), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[1], '5552345678'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[1], 'anything_555.5555555'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[1], '555.5555555_anything'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        // Test fail conditions EPP.
        $this->assertThat($rule->test($xml->field[2], 'bogus'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[2], '12345123451234512345'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[2], '123.1234'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[2], '23.1234'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[2], '3.1234'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        // Test fail conditions no plan.
        $this->assertThat($rule->test($xml->field[3], 'bogus'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[3], 'anything_555.5555555'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[3], '555.5555555x555_anything'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[3], '.5555555'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[3], '555.'), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        $this->assertThat($rule->test($xml->field[3], '1 2 3 4 5 6 '), $this->isFalse(), 'Line:' . __LINE__ . ' The rule should fail and return false.');
        // Test pass conditions.
        //For NANP
        $this->assertThat($rule->test($xml->field[0], '(555) 234-5678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[0], '1-555-234-5678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[0], '+1-555-234-5678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[0], '555-234-5678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[0], '1-555-234-5678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[0], '1 555 234 5678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        //For ITU-T
        $this->assertThat($rule->test($xml->field[1], '+555 234 5678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[1], '+123 555 234 5678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[1], '+2 52 34 55'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[1], '+5552345678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        //For EPP
        $this->assertThat($rule->test($xml->field[2], '+123.1234'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[2], '+23.1234'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[2], '+3.1234'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[2], '+3.1234x555'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        //For no plan
        $this->assertThat($rule->test($xml->field[3], '555 234 5678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[3], '+123 555 234 5678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[3], '+2 52 34 55'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[3], '5552345678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[3], '+5552345678'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[3], '1 2 3 4 5 6 7'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
        $this->assertThat($rule->test($xml->field[3], '123451234512'), $this->isTrue(), 'Line:' . __LINE__ . ' The rule should pass and return true.');
    }
开发者ID:nprasath002,项目名称:joomla-platform,代码行数:63,代码来源:JFormRuleTelTest.php

示例14: create_data

 function create_data()
 {
     $svg_file = find_file($this->paths['tempdir'], '.svg');
     $return = array();
     if (empty($svg_file)) {
         zn_delete_folder($this->paths['tempdir']);
         $return['message'] = 'The zip did not contained any svg files.';
     }
     $file_data = file_get_contents(trailingslashit($this->paths['tempdir']) . $svg_file);
     if (!is_wp_error($file_data) && !empty($file_data)) {
         $xml = simplexml_load_string($file_data);
         $font_attr = $xml->defs->font->attributes();
         $this->font_name = (string) $font_attr['id'];
         $icon_list = array();
         $glyphs = $xml->defs->font->children();
         $class = '';
         foreach ($glyphs as $item => $glyph) {
             if ($item == 'glyph') {
                 $attributes = $glyph->attributes();
                 $unicode = (string) $attributes['unicode'];
                 $d = (string) $attributes['d'];
                 if ($class != 'hidden' && !empty($d)) {
                     $unicode_key = trim(json_encode($unicode), '\\\\"');
                     if ($item == 'glyph' && !empty($unicode_key) && trim($unicode_key) != '') {
                         $icon_list[$this->font_name][$unicode_key] = $unicode_key;
                     }
                 }
             }
         }
         if (!empty($icon_list) && !empty($this->font_name)) {
             $icon_list_file = fopen($this->paths['tempdir'] . '/icon_list.php', 'w');
             if ($icon_list_file) {
                 fwrite($icon_list_file, '<?php $icons = array();');
                 foreach ($icon_list[$this->font_name] as $unicode) {
                     if (!empty($unicode)) {
                         $delimiter = "'";
                         if (strpos($unicode, "'") !== false) {
                             $delimiter = '"';
                         }
                         fwrite($icon_list_file, "\r\n" . '$icons[\'' . $this->font_name . '\'][' . $delimiter . $unicode . $delimiter . '] = ' . $delimiter . $unicode . $delimiter . ';');
                     }
                 }
                 fclose($icon_list_file);
             } else {
                 zn_delete_folder($this->paths['tempdir']);
                 $return['message'] = 'There was a problem creating the icon list file';
                 return;
             }
             // RENAME ALL FILES SO WE CAN LOAD THEM BY FONT NAME
             $this->rename_files();
             // RENAME THE FOLDER WITH THE FONT NAME
             $this->rename_folder();
             // ADD FONT DATA TO FONT OPTION
             $this->add_font_data();
         }
     } else {
         $return['message'] = 'The svg file could not be opened.';
     }
     return $return;
 }
开发者ID:rock1media,项目名称:wordpress,代码行数:60,代码来源:class-icon-manager.php

示例15: handleResponse

 /**
  * Formats the response based on the set response_type
  *
  * @param array $response
  * @return array
  */
 protected function handleResponse($response)
 {
     if ($this->response_type === 'json') {
         return json_decode($response->getBody(), true);
     }
     return simplexml_load_string($response->getBody());
 }
开发者ID:nicklaw5,项目名称:laravel-whmcs,代码行数:13,代码来源:WhmcsCore.php


注:本文中的simplexml_load_string函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。