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


PHP parse_ini_string函数代码示例

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


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

示例1: entry

function entry(&$argv)
{
    if (is_file($argv[0])) {
        if (0 === substr_compare($argv[0], '.class.php', -10)) {
            $uri = realpath($argv[0]);
            if (null === ($cl = \lang\ClassLoader::getDefault()->findUri($uri))) {
                throw new \Exception('Cannot load ' . $uri . ' - not in class path');
            }
            return $cl->loadUri($uri)->literal();
        } else {
            if (0 === substr_compare($argv[0], '.xar', -4)) {
                $cl = \lang\ClassLoader::registerPath($argv[0]);
                if (!$cl->providesResource('META-INF/manifest.ini')) {
                    throw new \Exception($cl->toString() . ' does not provide a manifest');
                }
                $manifest = parse_ini_string($cl->getResource('META-INF/manifest.ini'));
                return strtr($manifest['main-class'], '.', '\\');
            } else {
                array_unshift($argv, 'eval');
                return 'xp\\runtime\\Evaluate';
            }
        }
    } else {
        return strtr($argv[0], '.', '\\');
    }
}
开发者ID:xp-runners,项目名称:main,代码行数:26,代码来源:entry.php

示例2: parse

 public function parse($ini, $file = false, $return = false)
 {
     // if $ini is a file..
     if ($file) {
         // preserve the original $ini var for later
         $path = $ini;
         // check if $ini param contains the relative/absolute
         // path to the config file by seeing if it exists
         if (!file_exists($path)) {
             // if it doesn't prepend the default config path
             $path = $this->path . $path;
             // make sure the config file now exists
             if (!file_exists($path)) {
                 // if not throw a Config exception
                 throw new ConfigException('Config file doesn\'t exist: ' . $ini);
             }
         }
     }
     // if $file is true we need to parse $ini as
     $parsed = $file ? parse_ini_file($ini, true) : parse_ini_string($ini, true);
     // if the return param is set we want to return the parsed
     // INI file instead of adding to the properties array
     if ($return) {
         return $parsed;
     }
     // loop through the parsed array and add
     // each section to the properties array
     foreach ($parsed as $section => $properties) {
         $this->properties[$section] = $properties;
     }
 }
开发者ID:aboxall,项目名称:v0.1-legacy,代码行数:31,代码来源:Config.php

示例3: setUp

 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $iniFilename = 'rposwwebclient_test.ini';
     $iniContent = file_get_contents($iniFilename, FILE_USE_INCLUDE_PATH);
     if (false === $iniContent) {
         throw new \Exception("Loading .ini file '{$iniFilename}' failed.");
     }
     // Parse ini content
     $this->ini = parse_ini_string($iniContent, true);
     if (false === $this->ini) {
         throw new \Exception('Parsing .ini file failed.');
     }
     $this->aliceJID = "testalice@{$this->ini['testosw']['server']}";
     $this->julietJID = "testjuliet@{$this->ini['testosw']['server']}";
     $this->romeoJID = "testromeo@{$this->ini['testosw']['server']}";
     $this->xmpp = new XMPP();
     $this->xmpp->connect($this->ini['testosw']['server'], $this->ini['testosw']['port']);
     $this->xmpp->login($this->ini['testosw']['adminname'], $this->ini['testosw']['adminpassword'], $this->ini['testosw']['resource']);
     $this->xmpp->addUser("testalice@{$this->ini['testosw']['server']}", 'secretAlice');
     $this->xmpp->addUser("testjuliet@{$this->ini['testosw']['server']}", 'secretJuliet');
     $this->xmpp->addUser("testromeo@{$this->ini['testosw']['server']}", 'secretRomeo');
     $this->xmpp->disconnect();
     $this->juliet = new XMPP();
     $this->juliet->connect($this->ini['testosw']['server'], $this->ini['testosw']['port']);
     $this->juliet->login('testjuliet', 'secretJuliet', $this->ini['testosw']['resource']);
     $this->romeo = new XMPP();
     $this->romeo->connect($this->ini['testosw']['server'], $this->ini['testosw']['port']);
     $this->romeo->login('testromeo', 'secretRomeo', $this->ini['testosw']['resource']);
     $this->alice = new XMPP();
     $this->alice->connect($this->ini['testosw']['server'], $this->ini['testosw']['port']);
     $this->alice->login('testalice', 'secretAlice', $this->ini['testosw']['resource']);
 }
开发者ID:sdrieling,项目名称:osw-RPOSWWebClient,代码行数:36,代码来源:XMPPTest.php

示例4: init

 /**
  * Use this to pass a bunch of data at once to the object
  *
  * @param $data , can be an array or a file of the types yaml, json or ini, PHP will be executed!
  * @param bool $override , by default all existing data are replaced
  */
 public static function init($data, $override = true)
 {
     $settingsObj = self::getInstance();
     if (is_string($data)) {
         ob_start();
         include $data;
         switch (FsUtils::getFileExtension($data)) {
             case 'yaml':
             case 'yml':
                 $data = Yaml::parse(ob_get_clean());
                 break;
             case 'json':
                 $data = json_decode(ob_get_clean(), 1);
                 break;
             case 'ini':
                 $data = parse_ini_string(ob_get_clean());
                 break;
         }
     }
     if ($override) {
         $settingsObj->data = $data;
     } else {
         $settingsObj->data = ArrayUtils::arrayMergeRecursiveDistinct($settingsObj->data, $data);
     }
 }
开发者ID:oat-sa,项目名称:jig,代码行数:31,代码来源:Settings.php

示例5: checkUpdate

 public function checkUpdate()
 {
     $this->log('检查更新. . .');
     $updateFile = $this->updateUrl . '/update.ini';
     $update = @file_get_contents($updateFile);
     if ($update === false) {
         $this->log('无法获取更新文件 `' . $updateFile . '`!');
         return false;
     } else {
         $versions = parse_ini_string($update, true);
         if (is_array($versions)) {
             $keyOld = 0;
             $latest = 0;
             $update = '';
             foreach ($versions as $key => $version) {
                 if ($key > $keyOld) {
                     $keyOld = $key;
                     $latest = $version['version'];
                     $update = $version['url'];
                 }
             }
             $this->log('发现新版本 `' . $latest . '`.');
             $this->latestVersion = $keyOld;
             $this->latestVersionName = $latest;
             $this->latestUpdate = $update;
             return $keyOld;
         } else {
             $this->log('无法解压更新文件!');
             return false;
         }
     }
 }
开发者ID:myhloli,项目名称:Tieba_Sign,代码行数:32,代码来源:index.php

示例6: lang

 public function lang($file = 'lang.ini')
 {
     // check language default
     $file_lang = dirname(ROOT) . DS . 'data' . DS . 'languages.json';
     if (file_exists($file_lang)) {
         $languages = json_decode(file_get_contents($file_lang));
         if (count($languages)) {
             foreach ($languages as $language) {
                 if (isset($language->default) && $language->default == 1) {
                     if (file_exists(ROOT . DS . 'data' . DS . $language->file)) {
                         $file = $language->file;
                     }
                 }
             }
         }
     }
     $file = ROOT . DS . 'data' . DS . $file;
     if (file_exists($file)) {
         $data = parse_ini_file($file);
         if ($data === false || $data == null) {
             $content = file_get_contents($file);
             $data = parse_ini_string($content);
         }
         return $data;
     } else {
         return false;
     }
 }
开发者ID:rootcave,项目名称:9livesprints-web,代码行数:28,代码来源:functions.php

示例7: get_real_value

 public function get_real_value($key)
 {
     $lang_format = $this->get_dir_format();
     foreach ($this->_lang_order as $lang_key) {
         // Se não for definido o idioma, cria a variável
         if (!isset($this->_lang_dir[$lang_key])) {
             $this->_lang_dir[$lang_key] = null;
         }
         // Se for false, ignora rapidamente
         if ($this->_lang_dir[$lang_key] === false) {
             continue;
         }
         // Gera o diretório de busca
         $lang_path = sprintf($lang_format, $lang_key);
         // Se o diretório não existir, avança
         if (!is_file($lang_path)) {
             $this->_lang_dir[$lang_key] = false;
             continue;
         }
         // Se o arquivo não estiver sido carregado, o faz
         if ($this->_lang_dir[$lang_key] === null) {
             $this->_lang_dir[$lang_key] = parse_ini_string(utf8_decode(file_get_contents($lang_path)), false);
         }
         // Se a chave não existir, avança
         if (!isset($this->_lang_dir[$lang_key][$key])) {
             continue;
         }
         // Por fim, retorna a informação desejada
         return $this->_lang_dir[$lang_key][$key];
     }
     // Em último caso, retorna null
     return null;
 }
开发者ID:rentalhost,项目名称:core,代码行数:33,代码来源:core_language.php

示例8: parse

 /**
  * Parse a Jin string
  *
  * @acces public
  * @param string $jin_string The Jin string to parse
  * @param boolean $assoc Whether JSON objects should be associative arrays
  * @return array The parsed Jin string as an associative array
  */
 public function parse($jin_string, $assoc = FALSE)
 {
     $collection = clone $this->collection;
     $jin_string = $this->removeWhitespace($jin_string);
     $jin_string = $this->removeNewLines($jin_string);
     $jin_string = trim($jin_string);
     foreach (parse_ini_string($jin_string, TRUE, INI_SCANNER_RAW) as $index => $values) {
         foreach ($values as $key => $value) {
             $leadch = strtolower($value[0]);
             $length = strlen($value);
             if (in_array($leadch, ['n', 't', 'f']) && in_array($length, [4, 5])) {
                 if (strtolower($value) == 'null') {
                     $values[$key] = NULL;
                 } elseif (strtolower($value) == 'true') {
                     $values[$key] = TRUE;
                 } elseif (strtolower($value) == 'false') {
                     $values[$key] = FALSE;
                 }
                 continue;
             } elseif (in_array($leadch, ['{', '['])) {
                 $values[$key] = json_decode($value, $assoc);
             } elseif (is_numeric($value)) {
                 $values[$key] = json_decode($value);
             }
             if ($values[$key] === NULL) {
                 throw new Flourish\ProgrammerException('Error parsing JSON data: %s', $value);
             }
         }
         $collection->set($index, $values);
     }
     return $collection;
 }
开发者ID:dotink,项目名称:jin,代码行数:40,代码来源:Parser.php

示例9: testParseIniStringEmptySuccess

 public function testParseIniStringEmptySuccess()
 {
     $array = parse_ini_string('', true);
     $this->assertEquals(array(), $array, "Empty string should parse to empty array");
     $array = parse_ini_string('foobar', true);
     $this->assertEquals(array(), $array, "Empty string should parse non ini string to array");
 }
开发者ID:gg1977,项目名称:frontend,代码行数:7,代码来源:CompatabilityTest.php

示例10: extractDsn

 /**
  * extractDsn
  *
  * @param   string  $dsn
  *
  * @return  array
  */
 public static function extractDsn($dsn)
 {
     // Parse DSN to array
     $dsn = str_replace(';', "\n", $dsn);
     $dsn = parse_ini_string($dsn);
     return $dsn;
 }
开发者ID:im286er,项目名称:windwalker,代码行数:14,代码来源:PdoHelper.php

示例11: job

 /**
  * Job
  *
  * This function is called by the Autorun script.
  */
 public function job()
 {
     $latest_version = parse_ini_string($this->CI->bw_curl->get_request('https://raw.github.com/Bit-Wasp/BitWasp/master/version.ini'));
     // Check the recent commits for an alert message
     $alert = $this->check_alerts();
     if ($alert !== FALSE) {
         $this->CI->load->model('alerts_model');
         // If the site has never seen this alert before, proceed:
         if ($this->CI->alerts_model->check($alert['message']) == FALSE) {
             // Log a message for the admin
             $log_message = "A serious alert has been trigged by the Bitwasp developers on " . $alert['date'] . ":<br />" . $alert['message'] . "<br />";
             $this->CI->logs_model->add('BitWasp Developers', 'Please respond to serious alert', $log_message, 'Alert');
             unset($alert['date']);
             // Record the alert.
             $this->CI->alerts_model->add($alert);
             // If the site is not in maintenance mode, put it there now.
             if ($this->CI->bw_config->maintenance_mode == FALSE) {
                 $this->CI->load->model('admin_model');
                 $this->CI->admin_model->set_mode('maintenance');
             }
         }
     }
     if ($latest_version !== FALSE && BITWASP_CREATED_TIME !== FALSE) {
         if ($latest_version['bitwasp_created_time'] > BITWASP_CREATED_TIME) {
             $this->CI->load->model('logs_model');
             if ($this->CI->logs_model->add('Version Checker', 'New BitWasp code available', 'There is a new version of BitWasp available on GitHub. It is recommended that you download this new version (using ' . BITWASP_CREATED_TIME . ')', 'Info')) {
                 return TRUE;
             }
         }
     }
     return TRUE;
 }
开发者ID:marketcoinfork,项目名称:BitWasp-Fork,代码行数:37,代码来源:Version_Checker.php

示例12: main

function main()
{
    $path = __DIR__ . '/bad_ini_quotes.ini';
    $x = file_get_contents($path);
    $y = parse_ini_string($x, true);
    var_dump($y);
}
开发者ID:badlamer,项目名称:hhvm,代码行数:7,代码来源:bad_ini_quotes.php

示例13: get_fpm_memory_limit

function get_fpm_memory_limit($fpmconf, $startsection = "global")
{
    if (!is_readable($fpmconf)) {
        return array();
    }
    $fpm = parse_ini_string("[{$startsection}]\n" . file_get_contents($fpmconf), true);
    // prepend section from parent so stuff is parsed correctly in includes that lack a leading section marker
    $retval = array();
    foreach ($fpm as $section => $directives) {
        foreach ($directives as $key => $value) {
            if ($section == "www" && $key == "php_admin_value" && isset($value['memory_limit'])) {
                $retval['php_admin_value'] = $value['memory_limit'];
            } elseif ($section == "www" && $key == "php_value" && isset($value['memory_limit']) && !isset($retval['php_value'])) {
                // an existing value takes precedence
                // we can only emulate that for includes; within the same file, the INI parser overwrites earlier values :(
                $retval['php_value'] = $value['memory_limit'];
            } elseif ($key == "include") {
                // values from the include don't overwrite existing values
                $retval = array_merge(get_fpm_memory_limit($value, $section), $retval);
            }
            if (isset($retval['php_admin_value'])) {
                // done for good as nothing can change this anymore, bubble upwards
                return $retval;
            }
        }
    }
    return $retval;
}
开发者ID:codefoco,项目名称:heroku-buildpack-php,代码行数:28,代码来源:autotune.php

示例14: getNodeSettings

 /**
  * Get the node settings from this form
  * @param boolean $updateValues set to true to get the submitted node settings, false to get the initial node settings
  * @return joppa\model\NodeSettings
  * @throws zibo\ZiboException when the form is not submitted and $updateValues is set to true
  * @throws zibo\library\validation\exception\ValidationException when the submitted settings are not valid and $updateValues is set to true
  */
 public function getNodeSettings($updateValues = true)
 {
     if (!$updateValues) {
         return $this->nodeSettings;
     }
     if (!$this->isSubmitted()) {
         throw new ZiboException('Form not submitted');
     }
     $settings = @parse_ini_string($this->getValue(self::FIELD_SETTINGS));
     if ($settings === false) {
         $error = error_get_last();
         $error = new ValidationError('error', '%error%', array('error' => $error['message']));
         $exception = new ValidationException();
         $exception->addErrors(self::FIELD_SETTINGS, array($error));
         throw $exception;
     }
     $nodeSettings = new NodeSettings($this->nodeSettings->getNode(), $this->nodeSettings->getInheritedNodeSettings());
     // set the values from the form
     $inheritPrefixLength = strlen(NodeSettings::INHERIT_PREFIX);
     foreach ($settings as $key => $value) {
         $inherit = false;
         if (strlen($key) > $inheritPrefixLength && strncmp($key, NodeSettings::INHERIT_PREFIX, $inheritPrefixLength) == 0) {
             $key = substr($key, $inheritPrefixLength);
             $inherit = true;
         }
         $nodeSettings->set($key, $value, $inherit);
     }
     return $nodeSettings;
 }
开发者ID:BGCX261,项目名称:zibo-svn-to-git,代码行数:36,代码来源:NodeSettingsForm.php

示例15: update

 function update($new_instance, $old_instance)
 {
     $current_language = strtolower(get_bloginfo('language'));
     // network lang parameter only accept 2 letters language code (pt, es, en)
     $lng = substr($current_language, 0, 2);
     $instance = $old_instance;
     $instance['cluster'] = strip_tags($new_instance['cluster']);
     $instance['title'] = strip_tags($new_instance['title']);
     $instance['url'] = strip_tags($new_instance['url']);
     $instance['results'] = strip_tags($new_instance['results']);
     if (!empty($instance['url']) and strpos($instance['url'], '?') === false) {
         $instance['url'] = $instance['url'] . "?";
     }
     $this->url = $instance['url'];
     $url_dia_ws = file_get_contents($instance['url'] . "&debug=true");
     $url_dia_ws = explode("<br/><!DOCTYPE", $url_dia_ws);
     $url_dia_ws = $url_dia_ws[0];
     $url_dia_ws = str_replace('<b>request:</b> ', '', $url_dia_ws);
     $url_dia_ws = trim($url_dia_ws);
     $instance['url_dia_ws'] = $url_dia_ws;
     $url = $instance['url_dia_ws'];
     $data = json_decode(file_get_contents($url), true);
     $instance['clusters'] = $data['diaServerResponse'][0]['facet_counts']['facet_fields'];
     $language_url = explode("/", $instance['url']);
     $language_url = str_replace(end($language_url), '', $instance['url']);
     $language_url .= "/locale/{$lng}/texts.ini";
     $instance['language_url'] = $language_url;
     $instance['language_content'] = file_get_contents($instance['language_url']);
     $instance['language_content'] = parse_ini_string($instance['language_content'], true);
     return $instance;
 }
开发者ID:juliotak,项目名称:bvs-site-wp-plugin,代码行数:31,代码来源:vhl_clusters_widget.php


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