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


PHP Conf::write方法代码示例

本文整理汇总了PHP中Conf::write方法的典型用法代码示例。如果您正苦于以下问题:PHP Conf::write方法的具体用法?PHP Conf::write怎么用?PHP Conf::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Conf的用法示例。


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

示例1: init

 static function init()
 {
     $fh = fopen("./log.txt", "w");
     try {
         fputs($fh, "start\n");
         $conf = new Conf(dirname(__FILE__) . "/../public/conf01.xml");
         print "user: " . $conf->get('user') . "\n";
         print "host: " . $conf->get('host') . "\n";
         $conf->set("pass", "newpass");
         $conf->write();
     } catch (FileException $e) {
         // permissions issue or non-existent file
         fputs($fh, "file exception\n");
         throw $e;
     } catch (XmlException $e) {
         fputs($fh, "xml exception\n");
         // broken xml
     } catch (ConfException $e) {
         fputs($fh, "conf exception\n");
         // wrong kind of XML file
     } catch (Exception $e) {
         fputs($fh, "general exception\n");
         // backstop: should not be called
     } finally {
         fputs($fh, "end\n");
         fclose($fh);
     }
 }
开发者ID:raulcarval,项目名称:tests,代码行数:28,代码来源:Runner.php

示例2: init

 static function init()
 {
     try {
         $config = new Conf("file.xml");
         $config->set('sex', 'male');
         // назначает значение
         $config->write();
         // записывает в файл
         echo "sex: " . $config->get('sex');
         // выводит значение
     } catch (FileException $e) {
         die($e->__toString());
         //файл не существует либо не доступен для записи
     } catch (XmlException $e) {
         die($e->__toString());
         //Повреждённый XML-файл
     } catch (ConfException $e) {
         die($e->__toString());
         //не корректный формат XML-файла
     } catch (Exception $e) {
         die($e->__toString());
         // Этот код не долже никогда вызываться
     }
 }
开发者ID:Overfinch,项目名称:oop,代码行数:24,代码来源:index.php

示例3: init

 static function init()
 {
     try {
         //~ $conf = new Conf( dirname(__FILE__)."/conf.broken.xml" );
         //~ $conf = new Conf( dirname(__FILE__)."/conf.unwriteable.xml" );
         $conf = new Conf("nonexistent/not_there.xml");
         print "user: " . $conf->get('user') . "\n";
         print "host: " . $conf->get('host') . "\n";
         $conf->set("pass", "newpass");
         $conf->write();
     } catch (FileException $e) {
         // permissions issue or non-existent file
         throw $e;
     } catch (XmlException $e) {
         throw $e;
         // broken xml
     } catch (ConfException $e) {
         throw $e;
         // wrong kind of XML file
     } catch (Exception $e) {
         throw $e;
         // backstop: should not be called
     }
 }
开发者ID:jabouzi,项目名称:projet,代码行数:24,代码来源:listing04.21.php

示例4: write

        $this->xml = simplexml_load_file($file);
    }
    function write()
    {
        file_put_contents($this->file, $this->xml->asXML());
    }
    function get($str)
    {
        $matches = $this->xml->xpath("/conf/item[@name=\"{$str}\"]");
        if (count($matches)) {
            $this->lastmatch = $matches[0];
            return (string) $matches[0];
        }
        return null;
    }
    function set($key, $value)
    {
        if (!is_null($this->get($key))) {
            $this->lastmatch[0] = $value;
            return;
        }
        $conf = $this->xml->conf;
        $this->xml->addChild('item', $value)->addAttribute('name', $key);
    }
}
$conf = new Conf(dirname(__FILE__) . "/conf01.xml");
print "user: " . $conf->get('user') . "\n";
print "host: " . $conf->get('host') . "\n";
$conf->set("pass", "newpass");
$conf->write();
开发者ID:jabouzi,项目名称:projet,代码行数:30,代码来源:listing04.19.php

示例5: trim

<?php

$hostname = trim(`hostname`);
switch ($hostname) {
    default:
        // Replace with production values
        $DEBUG = 0;
        $API_ENDPOINT = 'http://api.hasoffers.com/Api/json';
        break;
}
/**
 * Application Debugging
 *
 */
Conf::write('DEBUG', $DEBUG);
/**
 * Api Configuraion
 *
 */
Conf::write('ApiClient.Endpoint', $API_ENDPOINT);
Conf::write('ApiClient.Version', 2);
Conf::write('ApiClient.NetworkId', 'demo');
Conf::write('ApiClient.NetworkToken', 'NEThSQ1Ah92G8f7JYqQuO5hnsULkia');
/**
 * Api Configuraion
 *
 */
Conf::write('ENV.DefaultOfferId', 1);
Conf::write('ENV.CompanyName', 'HasOffers');
开发者ID:MrYogi,项目名称:hasoffers-promotional-platform,代码行数:29,代码来源:local-configuration.php


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