• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP putenv函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run

 public static function run()
 {
     spl_autoload_register(['Bootstrap', 'autoload']);
     putenv('LANG=en_US.UTF-8');
     setlocale(LC_CTYPE, 'en_US.UTF-8');
     date_default_timezone_set(@date_default_timezone_get());
     session_start();
     $session = new Session($_SESSION);
     $request = new Request($_REQUEST);
     $setup = new Setup($request->query_boolean('refresh', false));
     $context = new Context($session, $request, $setup);
     if ($context->is_api_request()) {
         (new Api($context))->apply();
     } else {
         if ($context->is_info_request()) {
             $public_href = $setup->get('PUBLIC_HREF');
             $x_head_tags = $context->get_x_head_html();
             require __DIR__ . '/pages/info.php';
         } else {
             $public_href = $setup->get('PUBLIC_HREF');
             $x_head_tags = $context->get_x_head_html();
             $fallback_html = (new Fallback($context))->get_html();
             require __DIR__ . '/pages/index.php';
         }
     }
 }
开发者ID:arter97,项目名称:h5ai,代码行数:26,代码来源:class-bootstrap.php


示例2: testTravisLogger

 /**
  * It should automatically switch to the travis logger if the
  * CONTINUOUS_INTEGRATION environment variable is set.
  */
 public function testTravisLogger()
 {
     putenv('CONTINUOUS_INTEGRATION=1');
     $container = new Container(['PhpBench\\Extension\\CoreExtension'], ['path' => 'hello', 'config_path' => '/path/to/phpbench.json']);
     $container->init();
     $this->assertEquals('travis', $container->getParameter('progress'));
 }
开发者ID:dantleech,项目名称:phpbench,代码行数:11,代码来源:CoreExtensionTest.php


示例3: translate

function translate($lang, $test = 0)
{
    global $LOCALE_PATH;
    putenv("LANGUAGE={$lang}");
    bindtextdomain("zarafa", "{$LOCALE_PATH}");
    if (STORE_SUPPORTS_UNICODE == false) {
        bind_textdomain_codeset('zarafa', "windows-1252");
    } else {
        bind_textdomain_codeset('zarafa', "utf-8");
    }
    textdomain('zarafa');
    setlocale(LC_ALL, $lang);
    $trans_array["Sent Items"] = _("Sent Items");
    $trans_array["Outbox"] = _("Outbox");
    $trans_array["Deleted Items"] = _("Deleted Items");
    $trans_array["Inbox"] = _("Inbox");
    $trans_array["Calendar"] = _("Calendar");
    $trans_array["Contacts"] = _("Contacts");
    $trans_array["Drafts"] = _("Drafts");
    $trans_array["Journal"] = _("Journal");
    $trans_array["Notes"] = _("Notes");
    $trans_array["Tasks"] = _("Tasks");
    $trans_array["Junk E-mail"] = _("Junk E-mail");
    return $trans_array;
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:25,代码来源:exec.zarafa7.foldersnames.php


示例4: before

function before($route)
{
    $lang_mapping = array('fr' => 'fr_FR');
    if (!isset($_SESSION['locale'])) {
        $locale = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
        $_SESSION['locale'] = strtolower(substr(chop($locale[0]), 0, 2));
    }
    $lang = $_SESSION['locale'];
    // Convert simple language code into full language code
    if (array_key_exists($lang, $lang_mapping)) {
        $lang = $lang_mapping[$lang];
    }
    $lang = "{$lang}.utf8";
    $textdomain = "localization";
    putenv("LANGUAGE={$lang}");
    putenv("LANG={$lang}");
    putenv("LC_ALL={$lang}");
    putenv("LC_MESSAGES={$lang}");
    setlocale(LC_ALL, $lang);
    setlocale(LC_CTYPE, $lang);
    $locales_dir = dirname(__FILE__) . '/i18n';
    bindtextdomain($textdomain, $locales_dir);
    bind_textdomain_codeset($textdomain, 'UTF-8');
    textdomain($textdomain);
    set('locale', $lang);
}
开发者ID:sheelarajeshkumar,项目名称:torclient_ynh,代码行数:26,代码来源:config.php


示例5: setLocaleOnCommand

 private function setLocaleOnCommand($command)
 {
     ob_start();
     putenv("LC_CTYPE=en_US.UTF-8");
     passthru($command);
     return ob_get_clean();
 }
开发者ID:ansarbek,项目名称:tuleap,代码行数:7,代码来源:ViewVCProxy.class.php


示例6: startMSS

 public static function startMSS()
 {
     $n = rand(100000000000.0, 1000000000000000.0);
     $rand = base_convert($n, 10, 36);
     $socketfile = "/tmp/php-connector-{$rand}.sock";
     putenv("CPANEL_PHPCONNECT_SOCKET={$socketfile}");
     self::$socketfile = $socketfile;
     $dir = dirname(__FILE__);
     $script = 'startMockSocketServer.php';
     $class = 'MockSocketServer.php';
     $basedir = realpath("{$dir}/../../..");
     $mockserverscript = "{$basedir}/{$script}";
     require_once "{$basedir}/{$class}";
     if (!file_exists($mockserverscript)) {
         self::fail("Mock socket server script '{$mockserverscript}' does not exist");
     }
     $cmd = "/usr/bin/php -f {$mockserverscript}";
     $arg = "socketfile={$socketfile}";
     $full_cmd = "nohup {$cmd} {$arg} > /dev/null 2>&1 & echo \$!";
     // > /dev/null
     $PID = exec($full_cmd);
     self::$mockSocketServerPID = $PID;
     $lookup = exec("ps -p {$PID} | grep -v 'PID'");
     sleep(1);
     if (empty($lookup)) {
         self::fail('Failed to start mock socket server');
     } elseif (!file_exists($socketfile)) {
         self::fail('Socket file does not exist: ' . $socketfile);
     }
 }
开发者ID:shirone,项目名称:publicapi-php,代码行数:30,代码来源:LiveapiTest.php


示例7: testItReturnsUsefulErrorIfUnknownAndInDevelopment

 public function testItReturnsUsefulErrorIfUnknownAndInDevelopment()
 {
     putenv('APP_ENV=development');
     $exception = new RuntimeException('Some message.');
     $handled = ExceptionHandler::handleException($exception);
     $this->assertEquals(['error' => $exception->getCode(), 'message' => $exception->getMessage(), 'trace' => $exception->getTraceAsString()], $handled);
 }
开发者ID:fuzz-productions,项目名称:image-resizer,代码行数:7,代码来源:ExceptionHandlerTest.php


示例8: toEnv

 /**
  * Makes it so the content is available in getenv()
  */
 public function toEnv()
 {
     $dots = $this->toDots($this->content);
     foreach ($dots as $dot_k => $dot_v) {
         putenv(sprintf('%s=%s', $dot_k, $dot_v));
     }
 }
开发者ID:null9beta,项目名称:Vars,代码行数:10,代码来源:TransformerTrait.php


示例9: createApplication

 /**
  * Creates the application.
  *
  * @return \Illuminate\Foundation\Application
  */
 public function createApplication()
 {
     putenv('DB_DEFAULT=sqlite_testing');
     $app = (require __DIR__ . '/../bootstrap/app.php');
     $app->make(Illuminate\Contracts\Console\Kernel::class)->bootstrap();
     return $app;
 }
开发者ID:nguyensuper,项目名称:TBEx-CMS,代码行数:12,代码来源:TestCase.php


示例10: setLocale

 /**
  * Sets the current locale code
  */
 public function setLocale($locale)
 {
     //Remove from master until I figure this out
     /*if (!$this->isLocaleSupported($locale)) {
           throw new Exceptions\LocaleNotSupportedException(
               sprintf('Locale %s is not supported', $locale)
           );
       }*/
     try {
         $gettextLocale = $locale . "." . $this->encoding;
         // All locale functions are updated: LC_COLLATE, LC_CTYPE,
         // LC_MONETARY, LC_NUMERIC, LC_TIME and LC_MESSAGES
         putenv("LC_ALL={$gettextLocale}");
         putenv("LANGUAGE={$gettextLocale}");
         setlocale(LC_ALL, $gettextLocale);
         // Domain
         $this->setDomain($this->domain);
         $this->locale = $locale;
         $this->session->set($locale);
         // Laravel built-in locale
         if ($this->configuration->isSyncLaravel()) {
             $this->adapter->setLocale($locale);
         }
         return $this->getLocale();
     } catch (\Exception $e) {
         $this->locale = $this->configuration->getFallbackLocale();
         $exceptionPosition = $e->getFile() . ":" . $e->getLine();
         throw new \Exception($exceptionPosition . $e->getMessage());
     }
 }
开发者ID:rpsimao,项目名称:laravel-gettext,代码行数:33,代码来源:Gettext.php


示例11: viewvc_utils_wrap_utf8_exec

function viewvc_utils_wrap_utf8_exec($command)
{
    ob_start();
    putenv("LC_CTYPE=en_US.UTF-8");
    passthru($command);
    return ob_get_clean();
}
开发者ID:rinodung,项目名称:tuleap,代码行数:7,代码来源:viewvc_utils.php


示例12: setEnvVariables

 /**
  * Set app environment variables
  *
  * @param string $root
  * @return void
  */
 public static function setEnvVariables($root = '/')
 {
     $configs = null;
     // Set custom handler to catch errors as exceptions
     set_error_handler(create_function('$severity, $message, $file, $line', 'throw new \\ErrorException($message, $severity, $severity, $file, $line);'));
     if (file_exists($root . '/.dev.env') && is_readable($root . '/.dev.env')) {
         $configs = file_get_contents($root . '/.dev.env');
     } else {
         if (file_exists($root . '/.dist.env') && is_readable($root . '/.dist.env')) {
             $configs = file_get_contents($root . '/.dist.env');
         } else {
             if (file_exists($root . '/.test.env') && is_readable($root . '/.test.env')) {
                 $configs = file_get_contents($root . '/.test.env');
             } else {
                 if (file_exists($root . '/.env') && is_readable($root . '/.env')) {
                     $configs = file_get_contents($root . '/.env');
                 } else {
                     throw new NotFoundException('No configuration file found.');
                 }
             }
         }
     }
     if (false === $configs || null !== error_get_last()) {
         throw new UnreadableException('Configuration not readable.');
     }
     // Restore original error handler
     restore_error_handler();
     $configs = explode("\n", trim($configs));
     array_map(function ($config) {
         // Remove whitespaces
         $config = preg_replace('(\\s+)', '', $config);
         // Add as environment variables
         putenv($config);
     }, $configs);
 }
开发者ID:jabranr,项目名称:lassi,代码行数:41,代码来源:Util.php


示例13: validateNonNative

 protected function validateNonNative()
 {
     // Check to see if Docker has been exported.
     if (!$this->envExported()) {
         $this->stdOut->writeln("<comment>Docker environment information not exported. Attempting from PLATFORM_DOCKER_MACHINE_NAME");
         if (getenv('PLATFORM_DOCKER_MACHINE_NAME')) {
             // Attempt to boot the Docker VM
             if (!Machine::start(getenv('PLATFORM_DOCKER_MACHINE_NAME'))) {
                 $this->stdOut->writeln("<error>Failed to start Docker machine</error>");
                 exit(1);
             }
         } else {
             $this->stdOut->writeln("<error>You need to start your Docker machine and export the environment information");
             exit(1);
         }
         // Export the Docker VM info on behalf of the user
         $this->dockerParams = Machine::getEnv(getenv('PLATFORM_DOCKER_MACHINE_NAME'));
         foreach ($this->dockerParams as $key => $value) {
             putenv("{$key}={$value}");
         }
     }
     // Give a Docker command a try.
     if (!Docker::available()) {
         $this->stdOut->writeln("<error>Unable to reach Docker service - try manually exporting environment variables.</error>");
         exit(1);
     }
 }
开发者ID:pjcdawkins,项目名称:platform-docker,代码行数:27,代码来源:DockerCommand.php


示例14: loadParamsAndArgs

 public function loadParamsAndArgs($self = null, $opts = null, $args = null)
 {
     parent::loadParamsAndArgs($self, $opts, $args);
     if (!empty($this->mOptions['wiki_id'])) {
         putenv("SERVER_ID={$this->mOptions['wiki_id']}");
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:task_runner.php


示例15: logData

 /**
  * logDiskUsageData
  *
  * Retrives data and logs it to file
  *
  * @param string $type type of logging default set to normal but it can be API too.
  * @return string $string if type is API returns data as string
  *	 *
  */
 public function logData($type = false)
 {
     $class = __CLASS__;
     $settings = Logger::$_settings->{$class};
     $timestamp = time();
     //get process data here
     $ps_args = '-Ao %cpu,%mem,pid,user,comm,args';
     putenv('COLUMNS=1000');
     $string = shell_exec("ps {$ps_args}");
     //$string = explode("\n", trim ($processData));
     //get log location
     $logdirname = sprintf($this->logdir, date('Y-m-d'));
     $logpath = LOG_PATH . $logdirname;
     //echo "LOG_PATH : " . $logpath . " \n";
     $filename = sprintf($this->logfile, $logdirname, $timestamp);
     //echo "FILENAME : " . $filename . " \n";
     //great log folder if it doesnt exist
     if (!file_exists($logpath)) {
         mkdir($logpath, 0777);
     }
     //read me on encoding array to disk instead
     //https://www.safaribooksonline.com/library/view/php-cookbook/1565926811/ch05s08.html
     //write out process data to file
     LoadUtility::safefilerewrite($filename, $string, "w", true);
     if ($type == "api") {
         return $string;
     } else {
         return true;
     }
 }
开发者ID:javinc,项目名称:loadavg,代码行数:39,代码来源:log.Process.php


示例16: smart_spam

function smart_spam($code)
{
    @putenv('GDFONTPATH=' . realpath('.'));
    $font = 'FONT.TTF';
    // antispam image height
    $height = 40;
    // antispam image width
    $width = 110;
    $font_size = $height * 0.6;
    $image = @imagecreate($width, $height);
    $background_color = @imagecolorallocate($image, 255, 255, 255);
    $noise_color = @imagecolorallocate($image, 20, 40, 100);
    /* add image noise */
    for ($i = 0; $i < $width * $height / 4; $i++) {
        @imageellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
    }
    /* render text */
    $text_color = @imagecolorallocate($image, 20, 40, 100);
    @imagettftext($image, $font_size, 0, 7, 29, $text_color, $font, $code) or die('Cannot render TTF text.');
    //output image to the browser *//*
    header('Content-Type: image/png');
    @imagepng($image) or die('imagepng error!');
    @imagedestroy($image);
    exit;
}
开发者ID:JozefAB,项目名称:neoacu,代码行数:25,代码来源:captcha.php


示例17: createLogger

 private function createLogger($ci = false)
 {
     putenv('CONTINUOUS_INTEGRATION' . ($ci ? '=1' : '=0'));
     $logger = new DotsLogger($this->timeUnit);
     $logger->setOutput($this->output->reveal());
     return $logger;
 }
开发者ID:stof,项目名称:phpbench,代码行数:7,代码来源:DotsLoggerTest.php


示例18: testExecuteWithActiveVirtphpEnv

 /**
  * @covers Virtphp\Command\DestroyCommand::execute
  */
 public function testExecuteWithActiveVirtphpEnv()
 {
     // Create directory for testing
     $dir = __DIR__ . '/footest';
     if (!file_exists($dir) && !mkdir($dir)) {
         $this->markTestSkipped('Unable to create a directory for testing');
     }
     putenv("VIRTPHP_ENV_PATH={$dir}");
     $destroyerMock = null;
     $command = $this->getMock('Virtphp\\Command\\DestroyCommand', array('getHelperSet', 'getWorker', 'getEnvironments'));
     $command->expects($this->any())->method('getHelperSet')->will($this->returnCallback(function () {
         return new HelperSetMock();
     }));
     $command->expects($this->any())->method('getWorker')->will($this->returnCallback(function ($name, $args) use(&$destroyerMock) {
         $destroyerMock = new DestroyerMock($name, $args);
         return $destroyerMock;
     }));
     $command->expects($this->any())->method('getEnvironments')->will($this->returnValue(array($dir => array('name' => '', 'path' => ''))));
     $execute = new \ReflectionMethod('Virtphp\\Command\\DestroyCommand', 'execute');
     $execute->setAccessible(true);
     $input = new ArgvInput(array('file.php', $dir), $command->getDefinition());
     $output = new TestOutput();
     $result = $execute->invoke($command, $input, $output);
     $this->assertFalse($result);
     $this->assertCount(1, $output->messages);
     $this->assertEquals('You must deactivate this virtual environment before destroying it!', $output->messages[0]);
     // Clean up created directory
     rmdir($dir);
 }
开发者ID:Ryan4021,项目名称:virtphp,代码行数:32,代码来源:DestroyCommandTest.php


示例19: testEnv

 public function testEnv()
 {
     $this->assertTrue(Env::init());
     putenv('FOO=123');
     $this->assertSame(123, env('FOO'));
     $this->assertFalse(Env::init());
 }
开发者ID:oscarotero,项目名称:env,代码行数:7,代码来源:ConversionTest.php


示例20: ADODB_informix72

 function ADODB_informix72()
 {
     // alternatively, use older method:
     //putenv("DBDATE=Y4MD-");
     // force ISO date format
     putenv('GL_DATE=%Y-%m-%d');
 }
开发者ID:OberjukhtinIA0VWV0Allokuum,项目名称:testmasteke.leo,代码行数:7,代码来源:adodb-informix72.inc.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP putlog函数代码示例发布时间:2022-05-15
下一篇:
PHP put_login_link函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap