本文整理汇总了PHP中write函数的典型用法代码示例。如果您正苦于以下问题:PHP write函数的具体用法?PHP write怎么用?PHP write使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了write函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
function write(XMLWriter $xml, $data)
{
foreach ($data as $_key => $value) {
// check the key isnt a number, (numeric keys invalid in XML)
if (is_numeric($_key)) {
$key = 'element';
} else {
if (!is_string($_key) || empty($_key) || strncmp($_key, '_', 1) === 0) {
continue;
} else {
$key = $_key;
}
}
$xml->startElement($key);
// if the key is numeric, add an ID attribute to make tags properly unique
if (is_numeric($_key)) {
$xml->writeAttribute('id', $_key);
}
// if the value is an array recurse into it
if (is_array($value)) {
write($xml, $value);
} else {
$xml->text($value);
}
$xml->endElement();
}
}
示例2: publish
function publish($table, $menu)
{
global $mysql;
// get the new menu
$section = $_POST['menu'];
$menu = $_POST['menu'];
$title = $_POST['title'];
// CLEAR CURRENT TABLE
$sql = "TRUNCATE TABLE " . $table;
$query = $mysql->sql_query($sql);
// INSERT NEW DATA IN THE TABLE
$fields = array('type', 'txt_fr', 'txt_en', 'price');
$insert = array();
foreach ($_POST['type'] as $key => $_) {
$item = array();
foreach ($fields as $field) {
$var = $_POST[$field][$key];
$value = $var ? '\'' . mysqli_real_escape_string($mysql->cndb, stripslashes($var)) . '\'' : 'NULL';
array_push($item, $value);
}
array_push($insert, '(' . implode(',', $item) . ')');
}
$sql = 'INSERT INTO ' . $table . ' (' . implode(',', $fields) . ') VALUES ' . implode(',', $insert) . ';';
$query = $mysql->sql_query($sql);
write($table, 2);
save($table, $menu);
}
示例3: output
function output(array $values)
{
foreach (LANGS as $lang) {
if (array_key_exists($lang, $values)) {
write($lang, $values['file'], $values['key'], $values[$lang]);
}
}
}
示例4: shutdown
function shutdown()
{
global $socket;
if (!empty($socket)) {
write("QUIT");
fclose($socket);
}
}
示例5: postToSlack
function postToSlack($message)
{
$slackHookUrl = env('SLACK_HOOK_URL');
if (!empty($slackHookUrl)) {
runLocally('curl -s -S -X POST --data-urlencode payload="{\\"channel\\": \\"#' . env('SLACK_CHANNEL_NAME') . '\\", \\"username\\": \\"Release Bot\\", \\"text\\": \\"' . $message . '\\"}"' . env('SLACK_HOOK_URL'));
} else {
write('Configure the SLACK_HOOK_URL to post to slack');
}
}
示例6: waitForPort
public static function waitForPort($waiting_message, $ip, $port)
{
write($waiting_message);
while (!self::portAlive($ip, $port)) {
sleep(1);
write('.');
}
writeln("<fg=green>Up!</fg=green> Connect at <fg=yellow>=> {$ip}:{$port}</fg=yellow>");
}
示例7: execCurl
function execCurl($options)
{
static $n = 1;
$ch = curl_init('https://www.yiqihao.com/events/worldcupresult');
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
write($result);
echo "{$n}<br/>";
$n++;
}
示例8: write
function write($str)
{
static $firstTime = true;
if ($firstTime) {
ob_start();
ob_implicit_flush(false);
$firstTime = false;
write(str_repeat(' ', 1024 * 4));
}
echo $str, ob_get_clean();
flush();
}
示例9: criaXML
function criaXML($response)
{
$xml = new XmlWriter();
$xml->openMemory();
$xml->startDocument('1.0', 'UTF-8');
$xml->startElement('bvs');
write($xml, $response);
$xml->endElement();
header("Content-Type:text/xml");
echo $xml->outputMemory(true);
die;
}
示例10: write
function write(IPGXMLWriter $xmlWriter, $data)
{
foreach ($data as $key => $value) {
if (is_array($value)) {
$xmlWriter->StartElement($key);
write($xmlWriter, $value);
$xmlWriter->EndElement($key);
continue;
}
$xmlWriter->WriteElement($key, $value);
}
}
示例11: write
function write(XMLWriter $xml, $data)
{
foreach ($data as $key => $value) {
if (is_array($value)) {
$xml->startElement($key);
write($xml, $value);
$xml->endElement();
continue;
}
$xml->writeElement($key, $value);
}
}
示例12: run
function run($request)
{
$tables = array("ProductGroup", "ProductGroup_Live", "Product", "Product_Live");
if (class_exists("ProductVariation")) {
$tables[] = "ProductVariation";
}
//todo: make list based on buyables rather than hard-coded.
foreach ($tables as $tableName) {
$classErrorCount = 0;
$removeCount = 0;
$updateClassCount = 0;
$rowCount = DB::query("SELECT COUNT(\"ImageID\") FROM \"{$tableName}\" WHERE ImageID > 0;")->value();
DB::alteration_message("<h2><strong>CHECKING {$tableName} ( {$rowCount} records ):</strong></h2>");
$rows = DB::query("SELECT \"ImageID\", \"{$tableName}\".\"ID\" FROM \"{$tableName}\" WHERE ImageID > 0;");
if ($rows) {
foreach ($rows as $row) {
$remove = false;
$classErrorCount += DB::query("\r\n\t\t\t\t\t\tSELECT COUNT (\"File\".\"ID\")\r\n\t\t\t\t\t\tFROM \"File\"\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\"File\".\"ID\" = " . $row["ImageID"] . "\r\n\t\t\t\t\t\t\tAND (\r\n\t\t\t\t\t\t\t \"ClassName\" = 'Image' OR\r\n\t\t\t\t\t\t\t \"ClassName\" = 'ProductVariation_Image' OR\r\n\t\t\t\t\t\t\t \"ClassName\" = ''\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t")->value();
DB::query("\r\n\t\t\t\t\t\tUPDATE \"File\"\r\n\t\t\t\t\t\tSET \"ClassName\" = 'Product_Image'\r\n\t\t\t\t\t\tWHERE\r\n\t\t\t\t\t\t\t\"File\".\"ID\" = " . $row["ImageID"] . "\r\n\t\t\t\t\t\t\tAND (\r\n\t\t\t\t\t\t\t \"ClassName\" = 'Image' OR\r\n\t\t\t\t\t\t\t \"ClassName\" = 'ProductVariation_Image' OR\r\n\t\t\t\t\t\t\t \"ClassName\" = ''\r\n\t\t\t\t\t\t\t);\r\n\t\t\t\t\t");
$image = Product_Image::get()->byID($row["ImageID"]);
if (!$image) {
$remove = true;
} elseif (!$image->getTag()) {
$remove = true;
}
if ($remove) {
$removeCount++;
DB::query("UPDATE \"{$tableName}\" SET \"ImageID\" = 0 WHERE \"{$tableName}\".\"ID\" = " . $row["ID"] . " AND \"{$tableName}\".\"ImageID\" = " . $row["ImageID"] . ";");
} elseif (!is_a($image, Object::getCustomClass("Product_Image"))) {
$updateClassCount++;
$image = $image->newClassInstance("Product_Image");
$image - write();
}
}
}
if ($classErrorCount) {
DB::alteration_message("<strong>{$tableName}:</strong> there were {$classErrorCount} files with the wrong class names. These have been fixed.", "deleted");
} else {
DB::alteration_message("<strong>{$tableName}:</strong> there were no files with the wrong class names. ", "created");
}
if ($removeCount) {
DB::alteration_message("<strong>{$tableName}:</strong> Removed {$removeCount} image(s) from products and variations because they do not exist in the file-system or database", "deleted");
} else {
DB::alteration_message("<strong>{$tableName}:</strong> All product images are accounted for", "created");
}
if ($updateClassCount) {
DB::alteration_message("<strong>{$tableName}:</strong> {$removeCount} image(s) did not match the requirement 'instanceOF Product_Image', this has been corrected.", "deleted");
} else {
DB::alteration_message("<strong>{$tableName}:</strong> All product images instancesOF Product_Image", "created");
}
}
}
示例13: error
function error($code)
{
global $message, $text, $score, $timeused;
echo $code . '\\n';
$text = 'err';
$message = $code . '<br>เกรดเดอร์จะหยุดทำงาน และสามารถ start grader ด้วยตัวเองได้แล้ว';
$score = 0;
$timeused = 0;
degrade();
write();
shell_exec('sh /home/otog/otog/judge/run.sh');
die;
}
示例14: addRoute
protected function addRoute($route, $class, $routes)
{
if (file_exists('apps/' . $class . '.php')) {
if (empty($routes[$route])) {
file_put_contents('configs/router_config.ini', "\n" . $route . "=" . $class, FILE_APPEND);
} else {
write("Error: the route '" . $route . "' already exists.");
}
require_once 'apps/' . $class . '.php';
$description = $class::description();
write('[ ' . $route . ' ] - ' . $description);
} else {
write("Error: the class you specified doesn't exist in apps");
}
}
示例15: run
/**
* @brief function handling what the script does
*/
protected function run(&$params)
{
$routes = parse_ini_file('configs/router_config.ini');
if (!empty($routes[$params[1]])) {
unset($routes[$params[1]]);
$data = "";
foreach ($routes as $route => $class) {
$data .= $route . "=" . $class . "\n";
}
file_put_contents('configs/router_config.ini', $data);
write("route '" . $params[1] . "' removed.");
} else {
write("Error: the app you wanted to remove isn't listed in 'configs/router_config.ini'.");
}
}