本文整理匯總了PHP中print_r函數的典型用法代碼示例。如果您正苦於以下問題:PHP print_r函數的具體用法?PHP print_r怎麽用?PHP print_r使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了print_r函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: dump
function dump($var, $echo = true, $label = null, $strict = true)
{
$label = $label === null ? '' : rtrim($label) . ' ';
if (!$strict) {
if (ini_get('html_errors')) {
$output = print_r($var, true);
$output = "<pre>" . $label . htmlspecialchars($output, ENT_QUOTES) . "</pre>";
} else {
$output = $label . " : " . print_r($var, true);
}
} else {
ob_start();
var_dump($var);
$output = ob_get_clean();
if (!extension_loaded('xdebug')) {
$output = preg_replace("/\\]\\=\\>\n(\\s+)/m", "] => ", $output);
$output = '<pre>' . $label . htmlspecialchars($output, ENT_QUOTES, "GB2312") . '</pre>';
}
}
if ($echo) {
echo $output;
return null;
} else {
return $output;
}
}
示例2: sshiconn
function sshiconn($cmd, $pass, $ip, $sshp = 22)
{
$ip = $_REQUEST['ip'];
$pass = $_REQUEST['pass'];
$sshp = $_REQUEST['sshp'];
if (!isset($_REQUEST['sshp'])) {
$sshp = '22';
}
$connection = ssh2_connect($ip, $sshp);
if (!$connection) {
throw new Exception("fail: unable to establish connection\nPlease IP or if server is on and connected");
}
$pass_success = ssh2_auth_password($connection, 'root', $pass);
if (!$pass_success) {
throw new Exception("fail: unable to establish connection\nPlease Check your password");
}
$stream = ssh2_exec($connection, $cmd);
$errorStream = ssh2_fetch_stream($stream, SSH2_STREAM_STDERR);
stream_set_blocking($errorStream, true);
stream_set_blocking($stream, true);
print_r($cmd);
$output = stream_get_contents($stream);
fclose($stream);
fclose($errorStream);
ssh2_exec($connection, 'exit');
unset($connection);
return $output;
}
示例3: _group2ldap
/**
* convert objects with user data to ldap data array
*
* @param Tinebase_Model_FullUser $_user
* @param array $_ldapData the data to be written to ldap
*/
protected function _group2ldap(Tinebase_Model_Group $_group, array &$_ldapData)
{
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ENCRYPT ' . print_r($_ldapData, true));
}
if (isset($_ldapData['objectclass'])) {
$_ldapData['objectclass'] = array_unique(array_merge($_ldapData['objectclass'], $this->_requiredObjectClass));
}
if (isset($_ldapData['gidnumber'])) {
$gidNumber = $_ldapData['gidnumber'];
} else {
$gidNumber = $this->_getGidNumber($_group->getId());
}
// when we try to add a group, $_group has no id which leads to Tinebase_Exception_InvalidArgument in $this->_getGroupMetaData
try {
$metaData = $this->_getGroupMetaData($_group);
} catch (Tinebase_Exception_InvalidArgument $teia) {
$metaData = array();
}
if (!isset($metaData['sambasid'])) {
$_ldapData['sambasid'] = $this->_options[Tinebase_Group_Ldap::PLUGIN_SAMBA]['sid'] . '-' . (2 * $gidNumber + 1001);
$_ldapData['sambagrouptype'] = 2;
}
$_ldapData['displayname'] = $_group->name;
}
示例4: facebook
public function facebook()
{
$user = Socialize::with('facebook')->user();
// Do your stuff with user data.
print_r($user);
die;
}
示例5: search_ac_init
function search_ac_init(&$a)
{
if (!local_channel()) {
killme();
}
$start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
$count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
$search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
$search = $_REQUEST['query'];
}
// Priority to people searches
if ($search) {
$people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%" . dbesc($search) . "%' ");
$tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
}
$r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t{$people_sql_extra}\n\t\tORDER BY `xchan_name` ASC ", intval(local_channel()));
$results = array();
if ($r) {
foreach ($r as $g) {
$results[] = array("photo" => $g['xchan_photo_s'], "name" => '@' . $g['xchan_name'], "id" => $g['abook_id'], "link" => $g['xchan_url'], "label" => '', "nick" => '');
}
}
$r = q("select distinct term, tid, url from term where type in ( %d, %d ) {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG));
if (count($r)) {
foreach ($r as $g) {
$results[] = array("photo" => $a->get_baseurl() . '/images/hashtag.png', "name" => '#' . $g['term'], "id" => $g['tid'], "link" => $g['url'], "label" => '', "nick" => '');
}
}
header("content-type: application/json");
$o = array('start' => $start, 'count' => $count, 'items' => $results);
echo json_encode($o);
logger('search_ac: ' . print_r($x, true));
killme();
}
示例6: request
/**
* @param string $url
* @param string $method
* @param string $body
*
* @return FhirResponse
*/
public function request($url, $method = 'GET', $body = null)
{
$server_name = null;
foreach ($this->servers as $name => $server) {
if (substr($url, 0, strlen($server['base_url']))) {
$server_name = $name;
break;
}
}
$this->applyServerConfig($server_name ? $this->servers[$server_name] : array());
$this->http_client->setUri($url);
$this->http_client->setMethod($method);
if ($body) {
$this->http_client->setRawData($body, 'application/xml+fhir; charset=utf-8');
}
$response = $this->http_client->request();
$this->http_client->resetParameters();
if ($body = $response->getBody()) {
$use_errors = libxml_use_internal_errors(true);
$value = Yii::app()->fhirMarshal->parseXml($body);
$errors = libxml_get_errors();
libxml_use_internal_errors($use_errors);
if ($errors) {
throw new Exception("Error parsing XML response from {$method} to {$url}: " . print_r($errors, true));
}
} else {
$value = null;
}
return new FhirResponse($response->getStatus(), $value);
}
示例7: get_all_taxa
function get_all_taxa()
{
require_library('connectors/INBioAPI');
$func = new INBioAPI();
$paths = $func->extract_archive_file($this->dwca_file, "meta.xml");
$archive_path = $paths['archive_path'];
$temp_dir = $paths['temp_dir'];
$harvester = new ContentArchiveReader(NULL, $archive_path);
$tables = $harvester->tables;
if (!($this->fields["taxa"] = $tables["http://rs.tdwg.org/dwc/terms/taxon"][0]->fields)) {
debug("Invalid archive file. Program will terminate.");
return false;
}
self::build_taxa_rank_array($harvester->process_row_type('http://rs.tdwg.org/dwc/terms/Taxon'));
self::create_instances_from_taxon_object($harvester->process_row_type('http://rs.tdwg.org/dwc/terms/Taxon'));
self::get_objects($harvester->process_row_type('http://eol.org/schema/media/Document'));
self::get_references($harvester->process_row_type('http://rs.gbif.org/terms/1.0/Reference'));
self::get_agents($harvester->process_row_type('http://eol.org/schema/agent/Agent'));
self::get_vernaculars($harvester->process_row_type('http://rs.gbif.org/terms/1.0/VernacularName'));
$this->archive_builder->finalize(TRUE);
// remove temp dir
recursive_rmdir($temp_dir);
echo "\n temporary directory removed: " . $temp_dir;
print_r($this->debug);
}
示例8: print_r
/**
* @param $data
*/
public static function print_r($data)
{
echo "<pre>";
print_r($data);
echo "</pre>";
return;
}
示例9: createSymbolicLink
public static function createSymbolicLink($rootDir = null)
{
IS_MULTI_MODULES || exit('please set is_multi_modules => true');
$deper = Request::isCli() ? PHP_EOL : '<br />';
echo "{$deper}**************************create link start!*********************{$deper}";
echo '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|';
is_null($rootDir) && ($rootDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web');
is_dir($rootDir) || mkdir($rootDir, true, 0700);
//modules_static_path_name
// 遞歸遍曆目錄
$dirIterator = new \DirectoryIterator(APP_MODULES_PATH);
foreach ($dirIterator as $file) {
if (!$file->isDot() && $file->isDir()) {
$resourceDir = $file->getPathName() . DIRECTORY_SEPARATOR . Config::get('modules_static_path_name');
if (is_dir($resourceDir)) {
$distDir = ROOT_PATH . DIRECTORY_SEPARATOR . 'web' . DIRECTORY_SEPARATOR . $file->getFilename();
$cmd = Request::operatingSystem() ? "mklink /d {$distDir} {$resourceDir}" : "ln -s {$resourceDir} {$distDir}";
exec($cmd, $result);
$tip = "create link Application [{$file->getFilename()}] result : [" . (is_dir($distDir) ? 'true' : 'false') . "]";
$tip = str_pad($tip, 64, ' ', STR_PAD_BOTH);
print_r($deper . '|' . $tip . '|');
}
}
}
echo $deper . '|' . str_pad('', 64, ' ', STR_PAD_BOTH) . '|';
echo "{$deper}****************************create link end!**********************{$deper}";
}
示例10: addFailure
/**
* A failure occurred.
*
* @param PHPUnit_Framework_Test $test
* @param PHPUnit_Framework_AssertionFailedError $e
* @param float $time
*/
public function addFailure(PHPUnit_Framework_Test $test, PHPUnit_Framework_AssertionFailedError $e, $time)
{
$this->write('fail: ' . $e->getMessage());
$trace = current(PHPUnit_Util_Filter::getFilteredStacktrace($e, FALSE));
$this->write('trace: ' . print_r($trace, 1));
$this->currentTestPass = FALSE;
}
示例11: printTest
function printTest()
{
//Tracert HP817ACF
//$handle = printer_open() ;// Gets the default printer and prints to it.
//$handle = printer_open('\\\\192.168.1.247\\HP817ACF');
$handle = printer_open('HP Deskjet 3540 series (Network)');
// Gets the printer by name, to get printer name, go to devices and printers option, select a printer on the network , you will see the name on top
//HP Deskjet 3540 series (Network)
print_r($handle);
printer_start_doc($handle, "My Document");
printer_start_page($handle);
$font = printer_create_font("Arial", 72, 48, 400, false, false, false, 0);
printer_select_font($handle, $font);
printer_draw_text($handle, "test", 10, 10);
printer_delete_font($font);
printer_end_page($handle);
printer_end_doc($handle);
printer_close($handle);
//$fh = fopen("filename.ext", "rb");
// $content = fread($fh, filesize("filename.ext"));
//fclose($fh);
/*printer_set_option($handle, PRINTER_MODE, "text");
printer_write($handle, "TEXT To print");
printer_close($handle);
*/
}
示例12: __construct
/**
* Constructor
*
* @param array $options An array of arrays of IMAP options
* @param string $username
* @param string $password
*/
public function __construct(array $options = array(), $username = null, $password = null)
{
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($options, true));
}
parent::__construct($options, $username, $password);
}
示例13: role_editAct
/**
* 編輯角色
*/
public function role_editAct()
{
if (IS_POST) {
$id = intval(I("post.id"));
if ($id == 1) {
$this->error("超級管理員角色不能被修改!");
}
$data = D("Role")->create();
if ($data) {
if (D("Role")->save($data) !== false) {
$this->success("修改成功!", UC('Rbac/index'));
} else {
$this->error("修改失敗!" . D("Role")->getlastsql() . print_r($data, true));
}
} else {
$this->error(D("Role")->getError());
}
} else {
$id = intval(I("get.id"));
if (!$id) {
$this->error("非法操作!");
}
if ($id == 1) {
$this->error("超級管理員角色不能被修改!");
}
$data = D("Role")->field('id, status, remark, name')->where(array("id" => $id))->find();
if (!$data) {
$this->error("該角色不存在!");
}
$this->assign("headline", "編輯角色");
$this->assign("action_name", ACTION_NAME);
$this->assign("info", $data);
$this->display("Rbac:role_oper");
}
}
示例14: post
/**
* Handle a POST request for this map save ressource
* @param Request request
* @return Response
*/
function post($request)
{
$response = new Response($request);
if (isset($_POST['map'])) {
// Remove those slashes
if (get_magic_quotes_gpc()) {
$map = stripslashes($_POST['map']);
} else {
$map = $_POST['map'];
}
$map_obj = json_decode($map);
$geocacheManager = GeocacheManager::getInstance();
$geocaches = $geocacheManager->parseGeocaches($map_obj->{"geocaches"});
foreach ($geocaches as $geocache) {
$geocache->save();
}
$ownWaypoints = $geocacheManager->parseOwnWaypoints($map_obj->{"costumMarkers"});
foreach ($ownWaypoints as $ownWaypoint) {
$ownWaypoint->save();
}
$response->code = Response::OK;
$response->addHeader('Content-type', 'text/plain');
$response->body = print_r($map, true);
} else {
$response->code = Response::BADREQUEST;
}
return $response;
}
示例15: neat_r
function neat_r($arr, $return = false)
{
$out = array();
$oldtab = " ";
$newtab = " ";
$lines = explode("\n", print_r($arr, true));
foreach ($lines as $line) {
if (substr($line, -5) != "Array") {
$line = preg_replace("/^(\\s*)\\[[0-9]+\\] => /", "\$1", $line, 1);
}
foreach (array("Array" => "", "[" => "", "]" => "", " =>" => ":") as $old => $new) {
$out = str_replace($old, $new, $out);
}
if (in_array(trim($line), array("Array", "(", ")", ""))) {
continue;
}
$indent = "\n";
$indents = floor((substr_count($line, $oldtab) - 1) / 2);
if ($indents > 0) {
for ($i = 0; $i < $indents; $i++) {
$indent .= $newtab;
}
}
$out[] = $indent . trim($line);
}
$out = implode("<br/>", $out) . "\n";
if ($return == true) {
return $out;
}
echo $out;
}