本文整理汇总了PHP中arguments函数的典型用法代码示例。如果您正苦于以下问题:PHP arguments函数的具体用法?PHP arguments怎么用?PHP arguments使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了arguments函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: arguments
<?php
function arguments($argv)
{
$_ARG = array();
foreach ($argv as $arg) {
if (ereg('--([^=]+)=(.*)', $arg, $reg)) {
$_ARG[$reg[1]] = $reg[2];
} elseif (ereg('^-([a-zA-Z0-9])', $arg, $reg)) {
$_ARG[$reg[1]] = 'true';
} else {
$_ARG['input'][] = $arg;
}
}
return $_ARG;
}
// get args:
$args = arguments($argv);
$_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
include $args['index'];
$oConfig = \RainLoop\Api::Config();
$oConfig->SetPassword($args['password']);
echo $oConfig->Save() ? 'Admin password updated' : 'Admin password not updated';
示例2: array
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
if (function_exists('pcntl_fork')) {
if (pcntl_fork() != 0) {
exit;
}
}
include "init.php";
$supported_commands = array('debug' => false, 'gameport' => 6115, 'username' => '$Superhost', 'hostid' => 0, 'timeslot' => 100, 'creator' => '$Superhost', 'gamename' => 'Untitled', 'gamemode' => 'public', 'map_index' => -1, 'dotamode' => 'ar', 'channel' => 'bluelab', 'league_id' => 0, 'team1' => '', 'team2' => '', 'observer' => '', 'game_type' => 0);
//parse arguments
$arguments = arguments($_SERVER['argv']);
foreach ($supported_commands as $key => $value) {
if (empty($arguments[$key])) {
$cmd[$key] = $value ? $value : '';
} else {
$cmd[$key] = str_replace("'", '', $arguments[$key]);
}
}
$cmd['username'] = str_replace("\\", '', $cmd['username']);
$cmd['gamename'] = str_replace('_', ' ', $cmd['gamename']);
$client = new hostAssistance($cmd['hostid'], $server_addr, $server_port, $cmd['gameport'], $cmd['username'], $cmd['creator'], $cmd['gamename'], $cmd['map_index'], $cmd['gamemode']);
$client->process();
示例3: set_time_limit
#!/usr/bin/php
<?php
require_once "lib/Class.A2Billing.inc.php";
require_once "lib/Misc.inc.php";
require_once "lib/Provi/Class.IniImport.inc.php";
set_time_limit(0);
error_reporting(E_ALL ^ (E_NOTICE | E_WARNING));
$verbose = 1;
$dry_run = false;
$cli_args = arguments($argv);
if (!empty($cli_args['dry-run']) || !empty($cli_args['n'])) {
$dry_run = true;
}
if (!empty($cli_args['debug']) || !empty($cli_args['d'])) {
$verbose = 3;
} else {
if (!empty($cli_args['verbose']) || !empty($cli_args['v'])) {
$verbose = 2;
} else {
if (!empty($cli_args['silent']) || !empty($cli_args['q'])) {
$verbose = 0;
}
}
}
if (!empty($cli_args['config'])) {
define('DEFAULT_A2BILLING_CONFIG', $cli_args['config']);
}
// Get the periods
$files = $cli_args['input'];
if (empty($files)) {
echo "No file specified!\n";
示例4: file_get_contents
if (isset($_FILES['xml'])) {
$xml = file_get_contents($_FILES['xml']['tmp_name']);
} elseif (isset($_SERVER['HTTP_HOST'])) {
$REQUEST_VARS = array_merge($_GET, $_POST);
if (!isset($REQUEST_VARS['xml'])) {
die('xml not set');
}
header('Content-type: application/json');
header('X-JSON: true');
$xml = rawurldecode($REQUEST_VARS['xml']);
$xml = trim($xml);
$xml = str_replace('\\"', '"', $xml);
$xml = str_replace('"', "'", $xml);
$xml = preg_replace('/\\n/', ' ', $xml);
} elseif (isset($argv)) {
$cliArgs = arguments($argv);
if (isset($cliArgs['obj'])) {
$jsObject = $cliArgs['obj'];
} else {
$jsObject = "Fusion.appDefJson";
}
if (isset($cliArgs['file'])) {
$xml = file_get_contents($cliArgs['file']);
if (!$xml) {
die('file not found:' . $cliArgs['file']);
}
echo $jsObject . "=";
}
} else {
die('no XML input');
}
示例5: arg
function arg($name, $default = false)
{
global $arguments, $argv;
if (!isset($arguments)) {
$arguments = arguments($argv);
}
if (isset($arguments["commands"][$name])) {
return $arguments["commands"][$name];
} else {
return $default;
}
}
示例6: file_get_contents
exit;
}
if (isset($_POST['getpg'])) {
if (file_exists("progress.txt")) {
$c = file_get_contents("progress.txt");
if (empty($c)) {
$c = 1;
}
echo json_encode(array('result' => "success", 'progress' => $c));
} else {
echo json_encode(array('result' => "success", 'progress' => 1));
}
return;
}
if (isset($argv)) {
$arg = arguments($argv);
} else {
$arg = array();
}
if (count($arg)) {
//We're running this install from the command line
//usage: php install.php --dbhost=localhost --dbuser=root
// --dbpass=mypass --dbname=webstore --url=store.example.com
// --oldbname=webstorebak (optional)
//WARNING: This method of install does not run the environment check
//We cannot guarantee all libraries are installed
//(This is because command line php may differ from Apache server php)
if (isset($arg['help'])) {
showCommandLine();
}
if (isset($arg['dbupdate']) && $arg['dbupdate'] == 1) {
示例7: arguments
<?php
function arguments($pepe, $soiree, $course, $hopital, $clavier, $sexe)
{
if ($pepe == 'oui' && $soiree == 'non' && $course == 'non' && $hopital == 'oui' && $clavier == 'non' && $sexe == 'non') {
echo "<h2> Ok ! </h2>" . "<img src='img/car.jpg' alt='CharlesMobile' title='CharlesMobile'>";
} else {
if ($pepe == 'oui' && $soiree == 'non' && $course == 'non' && $hopital == 'oui' && $clavier == 'oui' && $sexe == 'non') {
echo "<h2> Peut-être, à condition que tu ranges ta chambre en rentrant ! </h2>";
} else {
echo "<h2> Dégage, punk ! </h2>";
}
}
}
if (!empty($_GET)) {
echo arguments($_GET['pepe'], $_GET['soiree'], $_GET['course'], $_GET['hopital'], $_GET['clavier'], $_GET['sexe']);
}
?>
</div> <!-- End container -->
<footer>
<a href="" class="github">Lien Github</a>
</footer>
<!-- JAVASCRIPT FILES -->
示例8: arguments
for ($i = 0; $i < $padding1; $i++) {
$paddingstr1 .= ' ';
}
$paddingstr2 = '';
for ($i = 0; $i < $padding2; $i++) {
$paddingstr2 .= ' ';
}
$help .= " -{$arg_array['short']},{$paddingstr1}--{$arg_array['long']}{$equal}{$paddingstr2}{$arg_array['help']}\n";
}
$help .= "\nEmail nicolasconnault@gmail.com for any suggestions or bug reports.\n";
if ($argc == 1 || in_array($argv[1], array('--help', '-help', '-h', '-?'))) {
echo $help;
die;
} else {
$settings['eolchar'] = "\n";
$argv = arguments($argv);
$argscount = 0;
foreach ($arguments as $arg_array) {
$value = null;
if (in_array($arg_array['short'], array_keys($argv))) {
$value = $argv[$arg_array['short']];
unset($argv[$arg_array['short']]);
} elseif (in_array($arg_array['long'], array_keys($argv))) {
$value = $argv[$arg_array['long']];
unset($argv[$arg_array['long']]);
}
if (!is_null($value)) {
$settings[$arg_array['long']] = $value;
$argscount++;
}
}
示例9: define
define('EMAIL_ALERT_ALL', 2);
define('EMAIL_SHARE_OFF', 0);
define('EMAIL_SHARE_ON', 1);
define('EMAIL_IS_SENDMAIL', true);
define('EMAIL_STATUS_OPEN', 'OPEN');
define('EMAIL_STATUS_TRANSMITTED', 'TRANSMITTED');
define('EMAIL_STATUS_BUFFERED', 'BUFFERED');
define('EMAIL_STATUS_ANSWERED', 'ANSWERED');
// read argv
function arguments($argv)
{
$ARG = array();
if (is_array($argv)) {
foreach ($argv as $arg) {
if (strpos($arg, '--') === 0) {
$compspec = explode('=', $arg);
$key = str_replace('--', '', array_shift($compspec));
$value = join('=', $compspec);
$ARG[$key] = $value;
} elseif (strpos($arg, '-') === 0) {
$key = str_replace('-', '', $arg);
if (!isset($ARG[$key])) {
$ARG[$key] = true;
}
}
}
}
return new ArrayObject($ARG, ArrayObject::ARRAY_AS_PROPS);
}
$_ARG = arguments($argv);
$_GAMEDATA = new ArrayObject(json_decode(file_get_contents(PERM_DATA . 'game.data.min.' . BOT_LANG), true), ArrayObject::ARRAY_AS_PROPS);
示例10: print_r
#!/usr/bin/php
<?php
/**
* @author David Mezquíriz Osés
*/
print_r(arguments($argv));
function arguments($args)
{
array_shift($args);
$endofoptions = false;
$ret = array('commands' => array(), 'options' => array(), 'flags' => array(), 'arguments' => array());
while ($arg = array_shift($args)) {
// if we have reached end of options,
//we cast all remaining argvs as arguments
if ($endofoptions) {
$ret['arguments'][] = $arg;
continue;
}
// Is it a command? (prefixed with --)
if (substr($arg, 0, 2) === '--') {
// is it the end of options flag?
if (!isset($arg[3])) {
$endofoptions = true;
// end of options;
continue;
}
$value = "";
$com = substr($arg, 2);
// is it the syntax '--option=argument'?
if (strpos($com, '=')) {
list($com, $value) = split("=", $com, 2);
示例11: arguments
<?php
// print_r(arguments($argv));
$parts = arguments($argv);
$filename = $parts["arguments"][0];
print "filename={$filename}\n";
$f1 = fopen($filename, "rb");
while (($buf = fread($f1, 8192)) != '') {
// Here, $buf is guaranted to contain data
$contents .= $buf;
}
if ($buf === FALSE) {
echo "THERE WAS AN ERROR READING\n";
}
fclose($f1);
$len = strlen($contents);
print "Length of read is {$len}\n";
$byte_array = unpack('C*', $contents);
//print_r($byte_array);
$i = 4;
while ($i <= $len) {
// print $byte_array[$i] . " ";
//if($i%40==0) print "\n";
$pattern = 0;
//Patterns to pull out
//123 0 0 0 3 0 0 0 128
//123 0 0 0 6 0 0 0 128 0 0 0 30 0 0 0 20 0 0 0 12 0 0 0 11 0 0 0 41 0 0 0 39 0 0 0 0 0 0 0
if ($byte_array[$i] == "123" && $byte_array[$i + 8] == "128") {
$pattern = 1;
print "\n\n\n";
$recordsize = 40;
示例12: set_include_path
<?php
/*
* Copyright 2013 Rnix Valentine
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
set_include_path(implode(PATH_SEPARATOR, array(realpath(dirname(__FILE__)), get_include_path())));
require 'libs/arguments.php';
require 'CliController.php';
$cmd = arguments($argv);
$controller = new Selenium2php\CliController();
$controller->run($cmd['arguments'], $cmd['options'], $cmd['flags']);