本文整理汇总了PHP中a函数的典型用法代码示例。如果您正苦于以下问题:PHP a函数的具体用法?PHP a怎么用?PHP a使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了a函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOrderDesc
public function testOrderDesc()
{
$this->assertTrue(CComparator::orderDesc(u("Hello there!"), u("Hello there!")) == 0);
$this->assertTrue(CComparator::orderDesc(u("A"), u("B")) > 0);
$this->assertTrue(CComparator::orderDesc(u("C"), u("B")) < 0);
$this->assertTrue(CComparator::orderDesc(u("¡Hola señor!"), u("¡Hola señor!")) == 0);
$this->assertTrue(CComparator::orderDesc(u("A"), u("B")) > 0);
$this->assertTrue(CComparator::orderDesc(u("C"), u("B")) < 0);
$this->assertTrue(CComparator::orderDesc(a("a", "b", "c"), a("a", "b", "c")) == 0);
$this->assertTrue(CComparator::orderDesc(a("b", "b", "c"), a("a", "b", "c")) < 0);
$this->assertTrue(CComparator::orderDesc(m(["one" => "a", "two" => "b", "three" => "c"]), m(["one" => "a", "two" => "b", "three" => "c"])) == 0);
$this->assertTrue(CComparator::orderDesc(m(["one" => "b", "two" => "b", "three" => "c"]), m(["one" => "a", "two" => "b", "three" => "c"])) < 0);
$this->assertTrue(CComparator::orderDesc(CTime::fromString("11/5/1955 12:00:00 PST"), CTime::fromString("11/5/1955 12:00:00 PST")) == 0);
$this->assertTrue(CComparator::orderDesc(CTime::fromString("11/5/1955 12:00:00 PST"), CTime::fromString("11/5/1985 12:00:00 PST")) > 0);
$this->assertTrue(CComparator::orderDesc(CTime::fromString("11/5/1985 12:00:01 PST"), CTime::fromString("11/5/1985 12:00:00 PST")) < 0);
$this->assertTrue(CComparator::orderDesc(true, true) == 0);
$this->assertTrue(CComparator::orderDesc(false, true) > 0);
$this->assertTrue(CComparator::orderDesc(true, false) < 0);
$this->assertTrue(CComparator::orderDesc(1234, 1234) == 0);
$this->assertTrue(CComparator::orderDesc(1234, 5678) > 0);
$this->assertTrue(CComparator::orderDesc(5678, 1234) < 0);
$this->assertTrue(CComparator::orderDesc(12.34, 12.34) == 0);
$this->assertTrue(CComparator::orderDesc(12.34, 56.78) > 0);
$this->assertTrue(CComparator::orderDesc(56.78, 12.34) < 0);
$this->assertTrue(CComparator::orderDesc(null, null) == 0);
$this->assertTrue(CComparator::orderDesc("Hello there!", "Hello there!") == 0);
$this->assertTrue(CComparator::orderDesc("A", "B") > 0);
$this->assertTrue(CComparator::orderDesc("C", "B") < 0);
$this->assertTrue(CComparator::orderDesc(CArray::fromElements("a", "b", "c"), CArray::fromElements("a", "b", "c")) == 0);
$this->assertTrue(CComparator::orderDesc(CArray::fromElements("a", "b", "c"), CArray::fromElements("b", "b", "c")) > 0);
$this->assertTrue(CComparator::orderDesc(CArray::fromElements("b", "b", "c"), CArray::fromElements("a", "b", "c")) < 0);
$this->assertTrue(CComparator::orderDesc(["one" => "a", "two" => "b", "three" => "c"], ["one" => "a", "two" => "b", "three" => "c"]) == 0);
$this->assertTrue(CComparator::orderDesc(["one" => "a", "two" => "b", "three" => "c"], ["one" => "b", "two" => "b", "three" => "c"]) > 0);
$this->assertTrue(CComparator::orderDesc(["one" => "b", "two" => "b", "three" => "c"], ["one" => "a", "two" => "b", "three" => "c"]) < 0);
}
示例2: avatar
function avatar($id)
{
$this->autoRender = false;
App::import('Component', 'File');
$file = new FileComponent();
if (!is_dir(PRODUCTIMAGES . DS . 'tmp')) {
$file->makeDir(PRODUCTIMAGES . DS . 'tmp');
} else {
$oldies = glob(PRODUCTIMAGES . DS . 'tmp' . DS . '*');
foreach ($oldies as $o) {
unlink($o);
}
}
if (!empty($this->params['form']['Filedata'])) {
if (strpos(strtolower(env('HTTP_USER_AGENT')), 'flash') === false || !$this->RequestHandler->isPost()) {
exit;
}
}
if (!empty($this->params['form']['Filedata'])) {
$tmp = $this->params['form']['Filedata'];
$ext = $file->returnExt($this->params['form']['Filedata']['name']);
$fn = 'original.' . $ext;
$the_temp = $this->params['form']['Filedata']['tmp_name'];
$temp_path = PRODUCTIMAGES . DS . 'tmp' . DS . $fn;
if (!is_dir(dirname($temp_path))) {
$file->makeDir(dirname($temp_path));
}
if (in_array($ext, a('jpg', 'jpeg', 'jpe', 'gif', 'png'))) {
if (is_uploaded_file($the_temp)) {
move_uploaded_file($the_temp, $temp_path);
}
}
}
exit(' ');
}
示例3: getAlert
/**
* Sets and shows an alert
*
* @param string $message
* @param string $type = "Error"
* @param boolean $URL = NULL
* @return string value
*/
function getAlert($message, $type = "error", $URL = NULL)
{
if (!is_null($URL)) {
$message = a(__(_($message)), encode($URL), TRUE);
}
if ($type === "error") {
return '<div id="alert-message" class="alert alert-error">
<a class="close">×</a>
' . __(_($message)) . '
</div>';
} elseif ($type === "success") {
unset($_POST);
return '<div id="alert-message" class="alert alert-success">
<a class="close">×</a>
' . __(_($message)) . '
</div>';
} elseif ($type === "warning") {
return '<div id="alert-message" class="alert alert-warning">
<a class="close">×</a>
' . __(_($message)) . '
</div>';
} elseif ($type === "notice") {
return '<div id="alert-message" class="alert alert-info">
<a class="close">×</a>
' . __(_($message)) . '
</div>';
}
}
示例4: testBeforeRender
function testBeforeRender()
{
$params = array('foo' => 'bar', 'baz' => array(1, 2, 3));
$this->_init($params);
$this->p->expectOnce('options', a(array('url' => array('?' => $params))));
$this->h->beforeRender();
}
示例5: testAddField
public function testAddField()
{
$urlQuery = new CUrlQuery();
$urlQuery->addField("name0", "value");
$urlQuery->addField("name1", true);
$urlQuery->addField("name2", 1234);
$urlQuery->addField("name3", 56.78);
$this->assertTrue($urlQuery->queryString()->equals("name0=value&name1=1&name2=1234&name3=56.78"));
$urlQuery = new CUrlQuery("name0=value0&name1=value1");
$urlQuery->addField("name2", "value2");
$this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2=value2"));
$urlQuery = new CUrlQuery("name0=value0&name1=value1");
$urlQuery->addField("name2", a("elem0", "elem1"));
$this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2[]=elem0&name2[]=elem1"));
$urlQuery = new CUrlQuery("name0=value0&name1=value1");
$urlQuery->addField("name2", m(["key0" => "value0", "key1" => "value1"]));
$this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2[key0]=value0&name2[key1]=value1"));
$urlQuery = new CUrlQuery("name0=value0&name1=value1");
$urlQuery->addField("name2", a(true, false));
$this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2[]=1&name2[]=0"));
$urlQuery = new CUrlQuery("name0=value0&name1=value1");
$urlQuery->addField("name2", a(1234, 5678));
$this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2[]=1234&name2[]=5678"));
$urlQuery = new CUrlQuery("name0=value0&name1=value1");
$urlQuery->addField("name2", a(12.34, 56.78));
$this->assertTrue($urlQuery->queryString()->equals("name0=value0&name1=value1&name2[]=12.34&name2[]=56.78"));
$urlQuery = new CUrlQuery();
$urlQuery->addField("arr", a("one", "two"));
$urlQuery->addField("map", m(["key0" => "one", "key1" => a("one", "two")]));
$this->assertTrue($urlQuery->queryString()->equals("arr[]=one&arr[]=two&map[key0]=one&map[key1][]=one&map[key1][]=two"));
}
示例6: a
/**
* @author Tõnis, Kaia *
* @param number $yks = 1
* @param number $kaks = 1
* @return string
*/
function a($yks, $kaks)
{
$c = 'B1234566';
// muutuja ja väärtus
$d = '<br />' . 'EHEE' . '<br />';
// muutuja ja väärtus
$x = $c - $d;
// muutuja milles lahutatakse eelnevalt määratud muutujad
// kui funktsiooni esimene parameeter on suurem kui üks ja teine parameeter väiksem kui kümme
if ($yks > 1 && $kaks < 10) {
$count = strlen(trim($x));
// loeta
$midagi = ucfirst($c);
// muutuja $c väärusel tehakse esimene täht suureks ja kirjutakse muutuja $midagi väärtuseks
}
$x .= ' (' . $yks . ', ' . $kaks . ')';
if ($c === $yks) {
$kaks = $c;
} else {
if (strlen($yks) > strlen($kaks)) {
echo "vale info on ikka äge";
} else {
$kaks = a($yks, $kaks);
}
}
$m = 567;
// while (1 > 0){ echo 'sure arvuti';}
return $x;
}
示例7: __construct
function __construct(Thread $thread)
{
parent::__construct($thread->getBoard());
$topLinks = div('', 'topLinks navLinks')->append('[' . a('Home', '/index') . ']')->append(' [' . a('Return', '/' . $this->board->getName() . '/') . ']');
if (!$thread->getBoard()->isSwfBoard()) {
$topLinks->append(' [' . a('Catalog', '/' . $this->board->getName() . '/catalog') . ']');
}
if (!$thread->getBoard()->isArchive() && $thread->isActive()) {
if ($thread->isClosed()) {
$this->appendToBody(el('h2', 'Thread is closed.'));
} else {
if (!isset($_SESSION['captcha'])) {
$_SESSION['captcha'] = rand(100000, 999999);
}
$this->appendToBody(Site::parseHtmlFragment('postForm.html', ['_board_', '_resto_', '_password_'], [$thread->getBoard()->getName(), $thread->getThreadId(), 'password']));
}
}
$this->appendToBody($topLinks);
$thread->loadAll();
$dur = secsToDHMS($thread->getPost($thread->getPosts() - 1)->getTime() - $thread->getPost(0)->getTime());
$board = div('', 'board');
if ($thread->getBoard()->isArchive()) {
$threadStats = Site::parseHtmlFragment("threadStats.html", ["__threadid__", "__posts__", "__posts_actual__", "__images__", "__images_actual__", "__lifetime__", "__deleted__", "<!--4chanLink-->", "<!--tag-->"], [$thread->getThreadId(), $thread->getChanPosts(), $thread->getPosts() - 1, $thread->getChanImages(), $thread->getImages() - 1, "{$dur[0]}d {$dur[1]}h {$dur[2]}m {$dur[3]}s", $thread->getDeleted(), $thread->isActive() ? "<a target='_blank' href='//boards.4chan.org/{$this->board->getName()}/thread/{$thread->getThreadId()}'>View on 4chan</a>" : "Thread is dead.", $thread->getTag() != null ? "<br>Tagged as: " . $thread->getTag() : ""]);
$board->append($threadStats);
} else {
$board->append('<hr>');
}
$this->appendToBody($board->append(div($thread->displayThread(), 'thread')));
$bottomLinks = $topLinks;
$this->appendToBody("<hr>" . $bottomLinks);
}
示例8: f
function f(&$n, &$b, $t)
{
foreach ($n as $p => $i) {
if (!is_array($i)) {
continue;
}
$o = [a($i)];
$l = $t($p);
foreach ($l as $h) {
if ($h == $p) {
continue;
}
if (!is_array($n[$h])) {
continue;
}
$o[] = a($n[$h]);
}
if (count($o) < 2) {
$n = $b;
$b = null;
return true;
}
$m = call_user_func_array('array_diff', $o);
if (count($m) == 1) {
l($p, reset($m));
return true;
}
}
return false;
}
示例9: show
/**
*/
function show()
{
$deepness = 3;
$ext = '.stpl';
$ext_len = strlen($ext);
foreach ((array) $this->_dir_array as $gname => $glob) {
foreach (range(1, $deepness) as $deep) {
$glob_pattern = $glob . '*' . str_repeat('/*', $deep) . $ext;
foreach (glob($glob_pattern) as $path) {
$name = substr(implode('/', array_reverse(array_slice(array_reverse(explode('/', $path)), 0, $deep))), 0, -$ext_len);
$names[$name][$path] = $path;
$theme = implode(array_slice(array_reverse(explode('/', $path)), $deep, 1));
$found_in[$path] = $gname . ' | ' . $theme;
}
}
}
ksort($names);
foreach ((array) $names as $name => $paths) {
$links = [];
foreach ($paths as $path) {
$links[] = a('/file_manager/edit/' . urlencode($path), 'Edit ' . $path, 'fa fa-edit', $found_in[$path]);
}
$body['<b>' . $name . '</b>'] = implode(' ', $links);
}
return html()->simple_table($body, ['condensed' => 1]);
}
示例10: __construct
public function __construct(Board $board, array $path)
{
parent::__construct($board);
$topLinks = div('', 'topLinks')->append('[' . a('Home', '/index') . ']')->append(' [' . a('Return', '/' . $this->board->getName() . '/') . ']');
if (!$board->isSwfBoard()) {
$topLinks->append(' [' . a('Catalog', '/' . $this->board->getName() . '/catalog') . ']');
}
$this->appendToBody($topLinks);
$this->appendToBody(el('h2', 'Board Search'));
try {
$method = $path[3] ?? "";
if (method_exists(self::class, $method)) {
$this->perPage = (int) get('perpage', 250);
$this->page = (int) get('page', 0);
$this->start = $this->perPage * $this->page;
$result = $this->{$path[3]}($path[4] ?? NULL);
$this->appendToBody(div($result->count . ' results.', 'centertext'));
$pages = $this->makePageSelector($result->count);
$this->appendToBody($pages);
$i = $this->start + 1;
foreach ($result->result as $post) {
$this->appendToBody(div($i++ . " >>", 'sideArrows') . PostRenderer::renderPost($post));
}
$this->appendToBody($pages);
} else {
$this->appendToBody("<h3>Invalid search parameter '{$method}' provided</h3>");
}
} catch (Exception $e) {
$this->appendToBody("<h3>Error: {$e->getMessage()}</h3>");
}
$this->appendToBody('<hr>' . $topLinks);
}
示例11: foo
function foo()
{
global $y;
$a = array('x' => a());
$a['b'] =& $y;
return $a;
}
示例12: GetPartialImage
function GetPartialImage($url)
{
$W = 150;
$H = 130;
$F = 80;
$STEP = 1.0 / $F;
$im = imagecreatefromjpeg($url);
$dest = imagecreatetruecolor($W, $H);
imagecopy($dest, $im, 0, 0, 35, 40, $W, $H);
$a = 1;
for( $y = $H - $F; $y < $H; $y++ )
{
for ( $x = 0; $x < $W; $x++ )
{
$i = imagecolorat($dest, $x, $y);
$c = imagecolorsforindex($dest, $i);
$c = imagecolorallocate($dest,
a($c['red'], $a),
a($c['green'], $a),
a($c['blue'], $a)
);
imagesetpixel($dest, $x, $y, $c);
}
$a -= $STEP;
}
header('Content-type: image/png');
imagepng($dest);
imagedestroy($dest);
imagedestroy($im);
}
示例13: edit
function edit()
{
if (!empty($this->data)) {
$this->Queries->retrieve_query($this->params['query_id'], true);
$query = $this->data['Query'];
$query['project'] = empty($this->Query->data['Project']) ? a() : array('Project' => $this->Query->data['Project']);
$query['project_id'] = $this->Query->data['Project']['id'];
$query['user_id'] = $this->Query->data['User']['id'];
$query['filters'] = array();
foreach ($this->params['form']['fields'] as $field) {
$this->Query->add_filter($field, $this->params['form']['operators'][$field], $this->params['form']['values'][$field]);
}
# @query.attributes = params[:query]
if (!empty($query['query_is_for_all'])) {
$query['project_id'] = null;
}
$query['is_public'] = $query['project'] && $this->User->is_allowed_to($this->current_user, ':manage_public_queries', $query['project']) || $this->current_user['admin'] ? true : false;
# @query.column_names = nil if params[:default_columns]
$this->Query->save($query);
if (empty($this->Query->validationErrors)) {
$this->Session->setFlash(__('Successful creation.', true), 'default', array('class' => 'flash flash_notice'));
$this->redirect(array('controller' => 'issues', 'action' => 'index', 'project_id' => $this->params['project_id']));
}
return;
} elseif (isset($this->params['query_id'])) {
$this->Queries->retrieve_query($this->params['query_id'], true);
$this->data['Query'] = $this->Query->data['Query'];
$this->data['Query']['default_columns'] = true;
if (empty($this->Query->data['Query']['project_id'])) {
$this->data['Query']['query_is_for_all'] = "1";
}
return;
}
$this->cakeError('error404');
}
示例14: foo
function foo()
{
$x = array(a());
$y =& $x[];
$y = 'asd';
return $x;
}
示例15: foo
function foo()
{
$x = array(a());
$y = null;
$x[] =& $y;
$y = 'asd';
return $x;
}