本文整理汇总了PHP中params函数的典型用法代码示例。如果您正苦于以下问题:PHP params函数的具体用法?PHP params怎么用?PHP params使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了params函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: props_to_xml
function props_to_xml()
{
# make the source xml
# make doc and root
$xml = new DomDocument();
$root = $xml->createElement('request');
$root->setAttribute('controller', params('controller'));
$root->setAttribute('action', params('action'));
$root = $xml->appendChild($root);
# unpack the props into xml
foreach ($this->props as $k => $v) {
# if it will become xml, do that, otherwise make a dumb tag
if (is_object($v) && method_exists($v, 'to_xml')) {
$obj_xml = $v->to_xml(array(), true, true);
$obj_xml = $xml->importNode($obj_xml->documentElement, true);
$root->appendChild($obj_xml);
} else {
$node = $xml->createElement($k);
if (strpos($v, '<') !== false || strpos($v, '>') !== false || strpos($v, '&') !== false) {
$cdata = $xml->createCDATASection($v);
} else {
$cdata = $xml->createTextNode($v);
}
$node->appendChild($cdata);
$node = $root->appendChild($node);
}
}
return $xml;
}
示例2: GamePage
function GamePage()
{
global $base_uri;
$uid = params('user');
if (!isset($_SESSION['uid'])) {
return 0;
} else {
createToken($_SESSION['uid']);
}
$reg = 0;
$shit = 0;
if (!isset($uid) || $uid == "") {
$uid = $_SESSION['uid'];
} else {
if (!check_registration($uid)) {
$reg = 1;
}
$shit = 1;
}
$user = getUserInfo($_SESSION['access_token'], $uid, 'photo_max');
if ($reg) {
register($uid, $user['first_name'], $user['last_name']);
}
echo $user['first_name'] . " " . $user['last_name'];
echo "<img src=\"" . $user['photo_max'] . "\" /><br><br>";
if ($shit) {
echo "<a href=\"/shit/" . $_SESSION['uid'] . "/" . $uid . "/" . getToken($_SESSION['uid']) . "\">shit</a><br>";
}
$friends = getUserFriends($_SESSION['access_token'], $uid);
foreach ($friends as $friend) {
echo $friend["first_name"] . " " . $friend["last_name"] . "<br>";
echo "<a href=\"{$base_uri}/game/" . $friend['uid'] . "\"><img src=\"" . $friend["photo_50"] . "\" /></a><hr>";
}
}
示例3: people_roles_delete
function people_roles_delete()
{
$cfg = $GLOBALS['cfg'];
$db = $GLOBALS['db'];
$role_id = intval(params('role_id'));
$person_id = intval(params('person_id'));
$connect = isset($_POST['connect']) ? true : false;
if ($connect) {
$role_id = intval($_POST['role_id']);
$person_id = intval($_POST['person_id']);
}
$result = $db->delete("DELETE FROM {$cfg['tblPersonHasRole']}\n WHERE rolle_id='{$role_id}'\n AND person_id='{$person_id}'\n LIMIT 1");
if (!$result) {
halt(SERVER_ERROR);
return;
}
if (isAjaxRequest()) {
if ($connect) {
$arrRoles = fetchRoles("WHERE {$cfg['tblRole']}.id = {$role_id}");
return js('people_roles/role.js.php', null, array('role' => array_pop($arrRoles)));
} else {
set('role', array('id' => $role_id));
set('person', array('id' => $person_id));
return js('people_roles/delete.js.php', null);
}
} else {
halt(HTTP_NOT_IMPLEMENTED);
}
}
示例4: form
/**
*
* @param type $form
* @param type $type_id
* @param type $rules
* @return type
*/
public function form($id = '', $module_id = '')
{
$this->data['module_id'] = $module_id;
if (!empty($id) and empty($_POST)) {
$this->data['post'] = $this->post->find($id, 1);
} else {
$post = params(array('title', 'description', 'tags', 'category_id'));
$post['id'] = $id;
$this->data['data'] = $post;
}
$this->load->library('form_validation');
$config = array(array('field' => 'title', 'label' => 'Заголовок топика', 'rules' => 'required|trim|max_length[255]'), array('field' => 'tags', 'label' => 'Тэги', 'rules' => 'required|trim|min_length[4]|max_length[255]'));
$this->form_validation->set_rules($config);
if ($this->form_validation->run($this) === FALSE) {
$this->data['modules_for_add'] = $this->settings['modules'];
if (!empty($id)) {
$this->data['modules'] = $this->module->find_all_for_post($id);
$post = $this->post->find($id, 1);
$this->call_modules($post, $module_id);
}
$this->template->render_to('content', $this->view . 'form', $this->data);
} else {
$post['user_id'] = (int) $this->current_user['id'];
$post['id'] = $this->post->save($post);
if ($post['id']) {
set_flash_ok('Отлично, топик создан, теперь можно его наполнять');
} else {
set_flash_error('Извини, ошибочка вышла');
}
redirect('post/form/' . $post['id']);
}
$this->draw();
}
示例5: routing
function routing($routes)
{
$url = $_SERVER['REQUEST_URI'];
//echo $url.'<br/>';
$url = str_replace("?" . $_SERVER['QUERY_STRING'], "", $url);
/*echo $_SERVER['QUERY_STRING'].'<br/>';
echo $url.'<br/>';*/
$params = params();
//print_r($params)."<br/>";
foreach ($routes as $route) {
//echo $route["url"]."<br/>";
if ($num_routes = preg_match($route["url"], $url, $matches) > 0) {
$params = array_merge($matches, $params);
break;
}
}
print_r($params) . "<br/>";
if ($num_routes == 0) {
exit("No se ha encontrado la ruta");
}
if ($route["controller"] != "") {
include CONTROLLERS_PATH . $route["controller"] . ".php";
}
if (file_exists(VIEWS_PATH . "layouts" . DS . $route["controller"] . ".php")) {
include VIEWS_PATH . "layouts" . DS . $route["controller"] . ".php";
} else {
include VIEWS_PATH . "layouts" . DS . "default.php";
}
$_SESSION["msg"]["warnings"] = "";
$_SESSION["msg"]["success"] = "";
}
示例6: log
function log($format = false, $address = false, $title = '')
{
$out = '';
if ($format === false) {
$format = self::$log_format;
}
switch ($format) {
case 'text':
$out .= $this->get_message() . "\n\n";
break;
case 'email':
case 'mail':
ob_start();
echo $this->get_message();
echo "\nFor URL: " . $_SERVER['REQUEST_URI'] . "\n\n";
echo "With Reqeust:";
var_export(params());
echo "\n\n";
echo "In " . $this->get_file() . " on line " . $this->get_line() . "\n";
mail($address, $title . ': ' . get_class($this) . ' Error', ob_get_clean());
break;
case 'html':
$out = $this->to_html();
break;
case 'xml':
$out .= $this->to_xml();
break;
case 'silent':
# do nothing
break;
}
error_log("Exception in " . $this->get_file() . ":" . $this->get_line() . " - " . $this->get_message());
return $out;
}
示例7: test_main_params
function test_main_params()
{
assert_empty(params());
assert_empty(params(null));
assert_true(is_array(params()));
assert_equal(params('first', 6), 6);
assert_equal(params('first'), 6);
assert_true(is_array(params()));
assert_equal(params('first', 12), 12);
assert_length_of(params(), 1);
params('my_array', 1, 2, 3, 4);
assert_true(is_array(params('my_array')));
assert_length_of(params('my_array'), 4);
assert_true(is_array(params()));
assert_length_of(params(), 2);
params(array('zero','one'));
assert_length_of(params(), 4);
assert_equal(params(0), 'zero');
assert_equal(params(1), 'one');
params(array(2 => 'two', 'first' => 'my one'));
assert_length_of(params(), 5);
assert_equal(params(2), 'two');
assert_equal(params('first'), 'my one');
assert_empty(params(null));
}
示例8: daemons_servers_delete
function daemons_servers_delete()
{
$cfg = $GLOBALS['cfg'];
$db = $GLOBALS['db'];
$server_id = intval(params('server_id'));
$daemon_id = intval(params('daemon_id'));
$arrService = $db->select("SELECT id\n FROM {$cfg['tblService']}\n WHERE server_id='{$server_id}'\n AND daemon_id='{$daemon_id}'");
if (!$arrService) {
halt(SERVER_ERROR);
return;
}
$id = $arrService[0]['id'];
$result = $db->delete("DELETE FROM {$cfg['tblService']}\n WHERE id='{$id}'\n LIMIT 1");
$resultForeign = $db->delete("DELETE FROM {$cfg['tblAccess']}\n WHERE dienst_id='{$id}'");
if (!$result || !$resultForeign) {
halt(SERVER_ERROR);
return;
}
set('server', array('id' => $server_id));
set('daemon', array('id' => $daemon_id));
if (isAjaxRequest()) {
return js('daemons_servers/delete.js.php', null);
} else {
halt(HTTP_NOT_IMPLEMENTED);
}
}
示例9: fz_dispatcher
function fz_dispatcher()
{
$controller = 'App_Controller_' . params('controller');
$controllerInstance = new $controller();
$controllerInstance->init();
return call_user_func(array($controllerInstance, params('action') . 'Action'));
}
示例10: changeRank
/**
* Change Rank controller.
*
* @author paul.michaud
* @author loic.bothorel
*/
function changeRank()
{
$promoParam = params('promo');
$tabPromo = getDistinctPromo();
set('tabPromo', $tabPromo);
set('promoParam', $promoParam);
return render('changeRank.html.php', 'layout/layout.html.php');
}
示例11: get_author_or_404
function get_author_or_404()
{
$author = find_author_by_id(filter_var(params('id'), FILTER_VALIDATE_INT));
if (is_null($author)) {
halt(NOT_FOUND, "This author doesn't exist.");
}
return $author;
}
示例12: how_are_you
function how_are_you()
{
$name = params('name');
if (empty($name)) {
halt(NOT_FOUND, "Undefined name.");
}
return html("I hope you are fine, {$name}.");
}
示例13: get_book_or_404
function get_book_or_404()
{
$book = find_book_by_id(filter_var(params('id'), FILTER_VALIDATE_INT));
if (is_null($book)) {
halt(NOT_FOUND, "This book doesn't exist.");
}
return $book;
}
示例14: extractParams
function extractParams()
{
global $namespace, $action, $jsonp;
// ...
$namespace = params('namespace');
$basedir = params('basedir');
$action = params('action');
$jsonp = params('jsonp');
}
示例15: get_VkMethod
function get_VkMethod($method_name, $parameters = array())
{
ksort($parameters);
$parameters = params($parameters);
$url = VKAPI_SERVER . $method_name . "?" . $parameters;
$result = doHttpRequest($url);
$result = urldecode($result);
$data = json_decode($result, true);
return $data["response"];
}