本文整理汇总了PHP中returns函数的典型用法代码示例。如果您正苦于以下问题:PHP returns函数的具体用法?PHP returns怎么用?PHP returns使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了returns函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDataInsideHelper
public function testDataInsideHelper()
{
echo returns($this->Captcha->webroot);
echo returns($this->Captcha->request->webroot);
echo returns($this->Captcha->data);
echo returns($this->Captcha->request->data);
}
示例2: compare
/**
* Compare two sets
*
* @return void
*/
public function compare()
{
if (count($this->args) !== 2) {
return $this->error('left and right are required.');
}
$left = realpath($this->args[0]);
$right = realpath($this->args[1]);
if (!$left || !$right) {
return $this->error('left or right is invalid.');
}
$content = file_get_contents($left);
preg_match_all('/\\.(icon-[a-z0-9-]+)\\s*\\:/', $content, $matches);
if (!$matches) {
return $this->error('invalid left');
}
$matchesLeft = $matches[1];
$content = file_get_contents($right);
preg_match_all('/\\.(icon-[a-z0-9-]+)\\s*\\:/', $content, $matches);
if (!$matches) {
return $this->error('invalid right');
}
$matchesRight = $matches[1];
$diffLeft = array();
foreach ($matchesRight as $m) {
if (!in_array($m, $matchesLeft)) {
continue;
}
$diffLeft[] = $m;
}
//$diffRight =
//echo returns($diffLeft);
$this->out('Common icons (overlapping classes):');
echo returns($diffLeft);
}
示例3: _testCompleteAuth
/**
* AuthExtComponentTest::_testCompleteAuth()
*
* @return void
*/
public function _testCompleteAuth()
{
$is = $this->Controller->TestAuthExt->completeAuth(1);
debug($is);
$this->assertTrue(!empty($is));
$is = $this->Controller->TestAuthExt->completeAuth(111);
echo returns($is);
$this->assertFalse($is);
}
示例4: testUse
public function testUse()
{
$key = $this->Qlogin->generate(array('controller' => 'test', 'action' => 'foo', 'bar'), 1);
$res = $this->Qlogin->translate($key);
echo returns($res);
pr($res);
$key = $this->Qlogin->generate('/test/foo/bar', 2);
$res = $this->Qlogin->translate($key);
echo returns($res);
pr($res);
}
示例5: testFieldsWithParam
public function testFieldsWithParam()
{
echo $this->_header(__FUNCTION__);
$this->Comment->Behaviors->detach('Jsonable');
$this->Comment->Behaviors->attach('Jsonable', array('fields' => array('details'), 'input' => 'param'));
$data = array('comment' => 'blabla', 'url' => 'www.dereuromark.de', 'name' => 'some Name', 'details' => 'z:vz|y:yz|x:xz');
$res = $this->Comment->save($data);
$this->assertTrue($res);
$res = $this->Comment->data;
echo returns($res);
$this->assertIdentical($res['JsonableTestModel']['details'], '{"z":"vz","y":"yz","x":"xz"}');
}
示例6: testMinIncAllowed
function testMinIncAllowed()
{
$this->Comment->Behaviors->detach('Geocoder');
$this->Comment->Behaviors->attach('Geocoder', array('real' => false, 'allow_inconclusive' => true));
// accuracy = 1
$data = array('city' => 'Neustadt');
$res = $this->Comment->save($data);
echo returns($this->Comment->Behaviors->Geocoder->Geocode->error()) . BR;
echo returns($this->Comment->Behaviors->Geocoder->Geocode->url()) . BR;
echo returns($this->Comment->Behaviors->Geocoder->Geocode->getResult()) . BR;
echo returns($res);
//echo returns($this->Comment->Behaviors->Geocoder->Geocode->debug());
$this->assertTrue(!empty($res['Comment']['lat']) && !empty($res['Comment']['lng']));
}
示例7: testFetch
function testFetch()
{
$url = 'http://maps.google.de';
$is = $this->HttpSocketLib->fetch($url);
//echo returns($is);
$this->assertTrue(!empty($is));
$url = 'http://sscfmaps.sfdgoogle.eede';
$is = $this->HttpSocketLib->fetch($url);
echo returns($is);
$this->assertFalse($is);
$error = $this->HttpSocketLib->error();
echo returns($error);
$this->assertTrue(!empty($error));
$this->assertEqual($this->HttpSocketLib->debug, 'curl');
}
示例8: testFind
public function testFind()
{
echo $this->_header(__FUNCTION__);
$res = $this->Comment->find('all', array());
$this->assertTrue(!empty($res));
echo returns($res);
$this->assertSame($res[0]['TestModel']['set_rate'], '0,1');
$this->assertSame($res[0]['TestModel']['rel_rate'], '-0,02');
echo BR . BR;
$res = $this->Comment->find('first', array());
$this->assertTrue(!empty($res));
echo returns($res);
$this->assertSame($res['TestModel']['set_rate'], '0,1');
$this->assertSame($res['TestModel']['rel_rate'], '-0,02');
$res = $this->Comment->find('count', array());
echo returns($res);
$this->assertSame($res[0][0]['count'], 2);
}
示例9: testStatic
function testStatic()
{
echo '<h2>StaticMap</h2>';
$m = array(array('address' => 'Berlin', 'color' => 'yellow', 'char' => 'Z', 'shadow' => 'true'), array('lat' => '44.2', 'lng' => '11.1', 'color' => '#0000FF', 'char' => '1', 'shadow' => 'false'));
$options = array('markers' => $this->GoogleMapV3->staticMarkers($m));
echo returns(h($options['markers'])) . BR;
$is = $this->GoogleMapV3->staticMapUrl($options);
echo h($is);
echo BR . BR;
$is = $this->GoogleMapV3->staticMapLink('MyLink', $options);
echo h($is);
echo BR . BR;
$is = $this->GoogleMapV3->staticMap($options);
echo h($is) . BR;
echo $is;
echo BR . BR;
$options = array('size' => '200x100', 'center' => true);
$is = $this->GoogleMapV3->staticMapLink('MyTitle', $options);
echo h($is);
echo BR . BR;
$attr = array('title' => 'Yeah');
$is = $this->GoogleMapV3->staticMap($options, $attr);
echo h($is) . BR;
echo $is;
echo BR . BR;
$pos = array(array('lat' => 48.1, 'lng' => '11.1'), array('lat' => 48.2, 'lng' => '11.2'));
$options = array('markers' => $this->GoogleMapV3->staticMarkers($pos));
$attr = array('url' => $this->GoogleMapV3->url(array('to' => 'Munich, Germany')));
$is = $this->GoogleMapV3->staticMap($options, $attr);
echo h($is) . BR;
echo $is;
echo BR . BR . BR;
$url = $this->GoogleMapV3->url(array('to' => 'Munich, Germany'));
$attr = array('title' => 'Yeah');
$image = $this->GoogleMapV3->staticMap($options, $attr);
$link = $this->GoogleMapV3->Html->link($image, $url, array('escape' => false, 'target' => '_blank'));
echo h($link) . BR;
echo $link;
}
示例10: deposit
/**
* Put money into the prepaid account
* @param $uid Id of user owning the account
* @param $amount Amount of money at the beginning
* @return boolean If $amount was successfully deposited
* @author gh 2011-09-13
*/
public function deposit($uid, $amount, $transaction = true)
{
if ($this->Behaviors->loaded('Loadable') && ($finalAmount = $this->finalAmount($amount))) {
$amount = $finalAmount;
}
$account = $this->account($uid);
$account[$this->alias]['amount'] += $amount;
$this->set($account);
$this->id = $account[$this->alias]['id'];
$this->enableLog(false);
$res = $this->save();
$this->enableLog(true);
if (!$res) {
die(returns($this->validationErrors));
return false;
}
$title = __('prepaidAccountDepositTitle');
$this->customLog(__('deposited') . ' (' . number_format($amount, 2) . ')', $this->id, array('title' => $title));
if ($transaction) {
$this->Transaction = ClassRegistry::init('Payment.Transaction');
$data = array('title' => $title, 'model' => $this->alias, 'foreign_id' => $this->id, 'status' => Transaction::STATUS_COMPLETED, 'amount' => $amount);
if (is_array($transaction)) {
$data = array_merge($data, $transaction);
}
$this->Transaction->initCustom('prepaid', $data);
}
return true;
}
示例11: testAppValidateTime
function testAppValidateTime()
{
$this->out($this->_header(__FUNCTION__));
$data = array('field' => '11:21:11');
$res = $this->App->validateTime($data);
$this->out(returns($res));
$this->assertTrue($res);
$data = array('field' => '11:71:11');
$res = $this->App->validateTime($data);
$this->out(returns($res));
$this->assertFalse($res);
$this->App->data = array($this->App->alias => array('before' => '2010-02-23 11:11:12'));
$data = array('field' => '2010-02-23 11:11:11');
$res = $this->App->validateTime($data, array('before' => 'before'));
$this->out(returns($res));
$this->assertTrue($res);
$this->App->data = array($this->App->alias => array('after' => '2010-02-23 11:11:12'));
$data = array('field' => '2010-02-23 11:11:11');
$res = $this->App->validateTime($data, array('after' => 'after'));
$this->out(returns($res));
$this->assertFalse($res);
}
示例12: returns
<?php
require 'core/core.php';
require 'model/model.php';
returns(success($services()));
示例13: testReverseGeocode
function testReverseGeocode()
{
$coords = array(array(-34.594445, -58.37446, 'Florida 1134-1200, Buenos Aires, Capital Federal, Argentinien'), array(48.8934, 8.70492, 'Bahnhofplatz 1, 75175 Pforzheim, Deutschland'));
foreach ($coords as $coord) {
$is = $this->GeocodeLib->reverseGeocode($coord[0], $coord[1]);
echo returns($is);
$this->assertTrue($is);
$is = $this->GeocodeLib->getResult();
$this->assertTrue(!empty($is));
echo returns($is);
$address = isset($is[0]) ? $is[0]['formatted_address'] : $is['formatted_address'];
$this->assertEqual($coord[2], $address);
}
}
示例14: pre
/**
* Shows pr() messages, even with debug = 0.
* Also allows additional customization.
*
* @param mixed $content
* @param bool $collapsedAndExpandable
* @param array $options
* - class, showHtml, showFrom, jquery, returns, debug
* @return string HTML
*/
function pre($var, $collapsedAndExpandable = false, $options = array())
{
$defaults = array('class' => 'cake-debug', 'showHtml' => false, 'showFrom' => false, 'jquery' => null, 'returns' => false, 'debug' => false);
$options += $defaults;
if ($options['debug'] && !Configure::read('debug')) {
return '';
}
if (php_sapi_name() === 'cli') {
return sprintf("\n%s\n", $options['returns'] ? returns($var) : print_r($var, true));
}
$res = '<div class="' . $options['class'] . '">';
$pre = '';
if ($collapsedAndExpandable) {
$js = 'if (this.parentNode.getElementsByTagName(\'pre\')[0].style.display==\'block\') {this.parentNode.getElementsByTagName(\'pre\')[0].style.display=\'none\'} else {this.parentNode.getElementsByTagName(\'pre\')[0].style.display=\'block\'}';
$jsJquery = 'jQuery(this).parent().children(\'pre\').slideToggle(\'fast\')';
if ($options['jquery'] === true) {
$js = $jsJquery;
} elseif ($options['jquery'] !== false) {
// auto
$js = 'if (typeof jQuery == \'undefined\') {' . $js . '} else {' . $jsJquery . '}';
}
$res .= '<span onclick="' . $js . '" style="cursor: pointer; font-weight: bold">Debug</span>';
if ($options['showFrom']) {
$calledFrom = debug_backtrace();
$from = '<em>' . substr(str_replace(ROOT, '', $calledFrom[0]['file']), 1) . '</em>';
$from .= ' (line <em>' . $calledFrom[0]['line'] . '</em>)';
$res .= '<div>' . $from . '</div>';
}
$pre = ' style="display: none"';
}
if ($options['returns']) {
$var = returns($var);
} else {
$var = print_r($var, true);
}
$res .= '<pre' . $pre . '>' . $var . '</pre>';
$res .= '</div>';
return $res;
}
示例15: _transformXml
/**
* flattens result array and returns clean record
* keys:
* - formatted_address, type, country, country_code, country_province, country_province_code, locality, sublocality, postal_code, route, lat, lng, location_type, viewport, bounds
* 2010-06-25 ms
*/
function _transformXml($record)
{
$res = array();
$components = array();
if (!isset($record['AddressComponent'][0])) {
$record['AddressComponent'] = array($record['AddressComponent']);
}
foreach ($record['AddressComponent'] as $c) {
$types = array();
if (isset($c['Type'])) {
//!is_array($c['Type'])
if (!is_array($c['Type'])) {
echo returns($record);
die;
}
$type = $c['Type'][0];
array_shift($c['Type']);
$types = $c['Type'];
} else {
$type = $c['type'];
}
if (array_key_exists($type, $components)) {
$components[$type]['name'] .= ' ' . $c['long_name'];
$components[$type]['abbr'] .= ' ' . $c['short_name'];
$components[$type]['types'] += $types;
}
$components[$type] = array('name' => $c['long_name'], 'abbr' => $c['short_name'], 'types' => $types);
}
$res['formatted_address'] = $record['formatted_address'];
$res['type'] = $this->_parse('type', $record);
if (array_key_exists('country', $components)) {
$res['country'] = $components['country']['name'];
$res['country_code'] = $components['country']['abbr'];
} else {
$res['country'] = $res['country_code'] = '';
}
if (array_key_exists('administrative_area_level_1', $components)) {
$res['country_province'] = $components['administrative_area_level_1']['name'];
$res['country_province_code'] = $components['administrative_area_level_1']['abbr'];
} else {
$res['country_province'] = $res['country_province_code'] = '';
}
if (array_key_exists('postal_code', $components)) {
$res['postal_code'] = $components['postal_code']['name'];
} else {
$res['postal_code'] = '';
}
if (array_key_exists('locality', $components)) {
$res['locality'] = $components['locality']['name'];
} else {
$res['locality'] = '';
}
if (array_key_exists('sublocality', $components)) {
$res['sublocality'] = $components['sublocality']['name'];
} else {
$res['sublocality'] = '';
}
if (array_key_exists('route', $components)) {
$res['route'] = $components['route']['name'];
if (array_key_exists('street_number', $components)) {
$res['route'] .= ' ' . $components['street_number']['name'];
}
} else {
$res['route'] = '';
}
//TODO: add more
$res['lng'] = $record['Geometry']['Location']['lat'];
$res['lat'] = $record['Geometry']['Location']['lng'];
$res['location_type'] = $record['Geometry']['location_type'];
if (!empty($record['Geometry']['Viewport'])) {
$res['viewport'] = array('sw' => $record['Geometry']['Viewport']['Southwest'], 'ne' => $record['Geometry']['Viewport']['Northeast']);
}
if (!empty($record['Geometry']['Bounds'])) {
$res['bounds'] = array('sw' => $record['Geometry']['Bounds']['Southwest'], 'ne' => $record['Geometry']['Bounds']['Northeast']);
}
return $res;
}