當前位置: 首頁>>代碼示例>>PHP>>正文


PHP k函數代碼示例

本文整理匯總了PHP中k函數的典型用法代碼示例。如果您正苦於以下問題:PHP k函數的具體用法?PHP k怎麽用?PHP k使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了k函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: spl_autoload_register

require_once 'VIH/configuration.php';
require_once 'konstrukt/konstrukt.inc.php';
require_once 'bucket.inc.php';
require_once 'Ilib/ClassLoader.php';
require_once 'Doctrine.php';
spl_autoload_register(array('Doctrine', 'autoload'));
class VIH_NotFoundComponent extends k_Component
{
    protected $template;
    function __construct(k_TemplateFactory $template)
    {
        $this->template = $template;
    }
    function dispatch()
    {
        $tpl = $this->template->create('404');
        $response = new k_HtmlResponse($tpl->render($this));
        $response->setStatus(404);
        return $response;
    }
}
class VIH_Document extends k_Document
{
}
$factory = new VIH_Factory();
$container = new bucket_Container($factory);
if (realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__) {
    $components = new k_InjectorAdapter($container, new VIH_Document());
    $components->setImplementation('k_DefaultPageNotFoundComponent', 'VIH_NotFoundComponent');
    k()->setComponentCreator($components)->run('VIH_Controller_Login_Root')->out();
}
開發者ID:vih,項目名稱:vih.dk,代碼行數:31,代碼來源:index.php

示例2: empty

      </div>
      <span id='copyright'>
        <?php 
$copyright = empty($config->site->copyright) ? '' : $config->site->copyright . '-';
$contact = json_decode($config->company->contact);
$company = (empty($contact->site) or $contact->site == $this->server->http_host) ? $config->company->name : html::a('http://' . $contact->site, $config->company->name, "target='_blank'");
echo "&copy; {$copyright}" . date('Y') . ' ' . $company . '&nbsp;&nbsp;';
?>
      </span>
      <span id='icpInfo'><?php 
echo $config->site->icpSN;
?>
</span>
      <div id='powerby'>
        <?php 
printf($lang->poweredBy, $config->version, k(), $config->version);
?>
      </div>
    </div>
  </footer>
   
<?php 
if ($config->debug) {
    js::import($jsRoot . 'jquery/form/min.js');
}
if (isset($pageJS)) {
    js::execute($pageJS);
}
/* Load hook files for current page. */
$extPath = dirname(dirname(dirname(__FILE__))) . '/common/ext/view/';
$extHookRule = $extPath . 'footer.front.*.hook.php';
開發者ID:wenyinos,項目名稱:chanzhieps,代碼行數:31,代碼來源:footer.html.php

示例3: setaccess

 function setaccess()
 {
     $rid = $_GET['rid'];
     $db = k("role");
     $role = $db->find($rid);
     $this->assign('role', $role);
     $node = Rbac::getNodeList($rid);
     if (!$node) {
         $this->error("還沒有設置權限節點,請設置", 'showaddnode');
     }
     $this->assign('node', $node);
     $this->display();
 }
開發者ID:jyht,項目名稱:v5,代碼行數:13,代碼來源:RbacControl.class.php

示例4: k

include_once "./vendor/autoload.php";
?>
<!doctype html>
<html lang="it">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">

    </head>
    <body>
	<?php 
if (isset($_GET)) {
    echo '<h2>$_GET</h2>';
    k($_GET);
}
if (isset($_POST)) {
    echo '<h2>$_POST</h2>';
    k($_POST);
}
if (isset($_REQUEST)) {
    echo '<h2>$_REQUEST</h2>';
    k($_REQUEST);
}
?>
    </body>
</html>
開發者ID:nervaccio,項目名稱:debug-target-post,代碼行數:29,代碼來源:index.php

示例5: implode

        if ($tags) {
            if ($user->send_category_as_array != 1) {
                $data['category'] = $tags;
            } else {
                $data['category'] = implode(',', $tags);
            }
        }
    }
    // Handle attachments
    $filename = false;
    foreach ($_FILES as $file) {
        // If a photo was included, set the filename to the downloaded file
        if (preg_match('/image/', $file['type'])) {
            $filename = $file['tmp_name'];
        }
        // Sometimes MMSs are sent with a txt file attached instead of in the body
        if (preg_match('/text\\/plain/', $file['type'])) {
            $content = trim(file_get_contents($file['tmp_name']));
            if ($content) {
                $data['content'] = $content;
            }
        }
    }
    $r = micropub_post_for_user($user, $data, $filename);
    if (k($r, 'location')) {
        $result = 'created post at ' . $r['location'];
    } else {
        $result = 'error creating post';
    }
    $app->response()->body($result);
});
開發者ID:voxpelli,項目名稱:Quill,代碼行數:31,代碼來源:hooks.php

示例6: nl2br

            break;
        default:
            print "<td></td></tr>";
            break;
    }
}
?>
  </table>
</TD></TR>

<TR style="background-color=#f5f5f5"><TD>
  <TABLE BORDER=0 CELLSPACING=2 CELLPADDING=0>
  <tr><td><b>Full text of the complaint</b> &nbsp; (<A HREF="JavaScript:window.print();">click here to print</A>)</td></tr>
  <tr><td>&nbsp;</td></tr>
  <tr><td><?php 
print nl2br(k($c->message));
?>
</td></tr>
  <tr><td>&nbsp;</td></tr>

  <?php 
if ($c->confirmed == "N") {
    ?>
     <tr><td align=center><FORM ACTION="complaint.php?c=<?php 
    print $c->id;
    ?>
&" METHOD=post><input type=submit value="Confirm Receipt"><input name=confirm type=hidden></form></td></tr>
  <?php 
} else {
    ?>
     <tr><td align=center><input type=button value="Back" onClick="JavaScript:location='members.php';"></td></tr>
開發者ID:RobertBohn,項目名稱:TellSafe-II,代碼行數:31,代碼來源:complaint.php

示例7: var_dump

// PHP5 64  allowed with warning "PHP Strict standards:  Only variables
//     should be passed by reference", but does not change the original argument
// HHVM, allowed quietly, but does not change the original argument
var_dump($z);
g($z = $z - 2);
// same as above
var_dump($z);
// g($z++);			// PHP5 32/64, Error: Only variables can be passed by reference
// HHVM,       Error: Cannot pass parameter 1 by reference
// ($z++)++;		// All 3, Error: unexpected '++'
g(--$z);
// PHP5 32, allowed quietly, but does not change the original argument
// PHP5 64  allowed with warning "PHP Strict standards:  Only variables
//     should be passed by reference", but does not change the original argument
// HHVM, allowed quietly, but does not change the original argument
// ----$z;			// All 3, Error: unexpected '--'
var_dump($z);
//*/
///*
function k()
{
    return 10;
}
var_dump(k());
g(k());
// PHP5 32, allowed quietly, but (presumably) does not change the original argument
// PHP5 64  allowed with warning "PHP Strict standards:  Only variables
//     should be passed by reference", but (presumably) does not change the original argument
// k() = 10;   // All 3, Error: Can't use function return value in write context
// HHVM, allowed quietly, but (presumably) does not change the original argument
//*/
開發者ID:mfsousa,項目名稱:php-langspec,代碼行數:31,代碼來源:passing_arguments.php

示例8: upload_file

function upload_file($type = 'img', $dir = '/media/')
{
    global $app;
    if ($type == "img") {
        $file_form = $_FILES['img-file'];
    } else {
        if ($type == "doc") {
            $file_form = $_FILES['doc-file'];
        }
    }
    $maxSize = 25000000;
    $imgExts = array("gif", "jpeg", "jpg", "png");
    $docExts = array("pdf", "doc", "docx", "xls", "xlsx", "csv");
    $allowedExts = array_merge($imgExts, $docExts);
    $allowedTypes = array("image/gif", "image/jpeg", "image/jpg", "image/pjpeg", "image/x-png", "image/png", "application/pdf", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.ms-excel", "application/msword");
    $file_obj = array();
    $file_obj['name'] = str_replace(" ", "_", $file_form['name']);
    $temp = explode(".", $file_obj['name']);
    $file_obj['ext'] = strtolower(end($temp));
    $file_obj['prefix'] = implode("", array_slice($temp, 0, -1));
    $file_obj['error'] = $file_form["error"];
    $file_obj['app_type'] = $file_form["type"];
    $file_obj['size'] = $file_form["size"];
    $file_obj['tmp_name'] = $file_form["tmp_name"];
    // Check for errors
    // File exists
    if (empty($file_form) or empty($file_obj['name'])) {
        $app['_error'] .= "Missing file or filename.<br>";
        return false;
    }
    // Allowed extension
    if (!in_array($file_obj['ext'], $allowedExts)) {
        k($allowedExts);
        $app['_error'] .= "<strong>" . $file_obj['ext'] . "</strong> is not an allowed extension.<br>";
        return false;
    } else {
        // Get file type from extension
        if (in_array($file_obj['ext'], $imgExts)) {
            $file_obj['type'] = "file-image";
        } else {
            $file_obj['type'] = "file-document";
        }
    }
    // Allowed type
    if (!in_array($file_obj['app_type'], $allowedTypes)) {
        $app['_error'] .= "<strong>" . $file_obj['app_type'] . "</strong> is not an allowed file type.<br>";
        return false;
    }
    // Size limit
    if ($file_obj['size'] > $maxSize) {
        $megs = number_format($file_obj['size'] / 1000000, 2);
        $allowedMegs = number_format($maxSize / 1000000, 2);
        $app['_error'] .= "<strong>{$megs} MB</strong> is too large. The maximum size allowed is {$allowedMegs} MB.<br>";
        return false;
    }
    // Other file upload errors
    if ($file_obj['error'] > 0) {
        $app['_error'] .= "Upload file error: " . $file_obj['error'] . "<br>";
        return false;
    }
    if ($app['_error'] === "") {
        $file_obj['path'] = $app['_root_url'] . $dir . $file_obj['name'];
        $file_obj['root_path'] = $app['_web_root'] . $dir . $file_obj['name'];
        if (file_exists($app['_web_root'] . $dir . $file_obj['name'])) {
            $app['_warning'] .= "<strong>Warning: </strong>" . $file_obj['name'] . " already exists. Updating file. <br>";
        }
        if (move_uploaded_file($file_obj['tmp_name'], $file_obj['root_path'])) {
            $app['_success'] .= "Uploaded file to <strong><a href='" . $file_obj['path'] . "' target='_blank'>" . $file_obj['path'] . "</a></strong>.<br>";
        } else {
            $app['_error'] .= "Error moving uploaded file to requested directory. <br>";
        }
        return $file_obj;
    } else {
        return false;
    }
}
開發者ID:jasonnug,項目名稱:simple-web-framework,代碼行數:76,代碼來源:include.php

示例9: fopen

<?php

include "../../class.krumo.php";
$fp = fopen(__FILE__, "r");
$a = array('first' => $fp, 'last' => new bar(), 'null_var' => null, 'float' => pi(), 'bool' => true, ' leading_space' => 6 * 8, 'trailing_space ' => 'grapes', 'middle space' => 'Mt. Rushmore', 'phones' => array(5036541278, 8714077831, 'x253'), 'long_str' => "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum...", 'empty_arr' => array(), 'func_str' => 'preg_replace', 'address' => array('street' => '123 Fake Street', 'city' => 'Portland', 'state' => 'Maine'), 'unixtime' => 1231241234, 'microtime' => microtime(1));
if (isset($_GET['short']) || php_sapi_name() === 'cli') {
    kd($a, KRUMO_EXPAND_ALL);
}
print "<h2>krumo capture</h2>\n";
$str = k(array('foo' => 'bar'), KRUMO_RETURN);
print $str;
print "<h2>krumo</h2>\n";
k(array('likes', 'kittens', 'and', 'dogs'));
print "<h2>krumo passing multiple args</h2>\n";
k('likes', 'kittens', 'and', 'dogs');
print "<h2>krumo + die()</h2>\n";
kd($a);
print "If you see this something is broken";
$k = new krumo();
class bar
{
    public $b = 'bb';
    public $a = 'aa';
    public function foo()
    {
        return 'bar';
    }
}
開發者ID:mmucklo,項目名稱:krumo,代碼行數:28,代碼來源:misc.php

示例10: ob_start

<?php

ob_start();
$ss_timer = microtime(true);
require_once '../../conf/global.conf.php';
//create_container();
k()->setComponentCreator(new \Slipstream\Common\Injector\BucketAdapter($i = create_container()))->setLog($debug_log_path)->setDebug($debug_enabled)->run('Slipstream\\JsonRest\\Component\\Root')->out();
//$i->get('Slipstream\Common\Log\Handler')->log($i->get('Slipstream\Common\ConfigurationInterface'),'Execution time');
$i->get('Slipstream\\Common\\Log\\Handler')->log(microtime(true) - $ss_timer, 'Execution time');
ob_end_flush();
開發者ID:jaanush,項目名稱:slipstream,代碼行數:10,代碼來源:index.php

示例11: k

        $response = ['latitude' => null, 'longitude' => null, 'locality' => null, 'region' => null, 'country' => null, 'best_name' => null, 'full_name' => null, 'timezone' => null, 'offset' => null, 'seconds' => null, 'localtime' => null];
        if (k($params, 'input')) {
            $adr = p3k\Geocoder::geocode($params['input']);
        } else {
            $lat = (double) $params['latitude'];
            $lng = (double) $params['longitude'];
            $response['latitude'] = $lat;
            $response['longitude'] = $lng;
            $adr = p3k\Geocoder::adrFromLocation($lat, $lng);
        }
        if ($adr) {
            $response['latitude'] = $adr->latitude;
            $response['longitude'] = $adr->longitude;
            $response['locality'] = $adr->localityName;
            $response['region'] = $adr->regionName;
            $response['country'] = $adr->countryName;
            $response['best_name'] = $adr->bestName;
            $response['full_name'] = $adr->fullName;
        }
        $timezone = p3k\Timezone::timezone_for_location($response['latitude'], $response['longitude'], k($params, 'date'));
        if ($timezone) {
            $response['timezone'] = $timezone->name;
            $response['offset'] = $timezone->offset;
            $response['seconds'] = $timezone->seconds;
            $response['localtime'] = $timezone->localtime;
        }
        json_response($app, $response);
    } else {
        json_response($app, ['error' => 'invalid_request', 'error_description' => 'Request was missing parameters'], 400);
    }
});
開發者ID:aaronpk,項目名稱:Atlas,代碼行數:31,代碼來源:geocode.php

示例12: array

            $username->addValidator('regex', false, array('/^[a-z]+/'));
            $username->addValidator('stringLength', false, array(6, 20));
            $username->setRequired(true);
            $username->addFilter('StringToLower');
            // Create and configure password element:
            $password = $form->createElement('password', 'password');
            $password->setLabel("Password");
            $password->addValidator('StringLength', false, array(6));
            $password->setRequired(true);
            // Add elements to form:
            $form->addElement($username);
            $form->addElement($password);
            // use addElement() as a factory to create 'Login' button:
            $form->addElement('submit', 'login', array('label' => 'Login'));
            // Since we're using this outside ZF, we need to supply a default view:
            $form->setView(new Zend_View());
            $this->form = $form;
        }
        return $this->form;
    }
}
class ZfThanks extends k_Component
{
    function renderHtml()
    {
        return sprintf("<p>%s</p>", htmlspecialchars($this->query('flare')));
    }
}
if (realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__) {
    k()->run('ZfRegistrationForm')->out();
}
開發者ID:RussellDias,項目名稱:konstrukt,代碼行數:31,代碼來源:index.php

示例13:

          <p>The token endpoint did not return an access token. The <code>access_token</code> parameter is the token the client will use to make requests to the Micropub endpoint.</p>
        <?php 
                }
                ?>

        <?php 
                if (!k($this->auth, 'me')) {
                    ?>
          <h4>Missing <code>me</code></h4>
          <p>The token endpoint did not return a "me" parameter. The <code>me</code> parameter lets this client know what user the token is for.</p>
        <?php 
                }
                ?>

        <?php 
                if (!k($this->auth, 'scope')) {
                    ?>
          <h4>Missing <code>scope</code></h4>
          <p>The token endpoint did not return a "scope" parameter. The <code>scope</code> parameter lets this client what permission the token represents.</p>
        <?php 
                }
                ?>

      <?php 
            }
            ?>

    <?php 
        }
        ?>
  <?php 
開發者ID:voxpelli,項目名稱:OwnYourGram,代碼行數:31,代碼來源:auth_callback.php

示例14: dirname

<?php

require_once dirname(__FILE__) . '/../config/global.inc.php';
k()->setComponentCreator(new k_InjectorAdapter(create_container()))->setLog($debug_log_path)->setDebug($debug_enabled)->run('components_Root')->out();
開發者ID:harrysame,項目名稱:PHP-MySQL,代碼行數:4,代碼來源:index.php

示例15: var_dump

{
    echo '$p ' . (isset($p) ? "is set\n" : "is not set\n");
    var_dump($p);
    return $p;
    // return undefined variable
}
$a = array(10, 20, 30);
var_dump($a);
$d =& k($a[0]);
var_dump($d);
var_dump($a);
$d =& k($a[5]);
// non-existant element going in
var_dump($d);
var_dump($a);
$d =& k($a["red"]);
// non-existant element going in
var_dump($d);
var_dump($a);
//*/
///*
// returning literals byRef is okay
function &m1()
{
    return NULL;
}
$d =& m1();
var_dump($d);
function &m2()
{
    return 1234;
開發者ID:jeremyadoux,項目名稱:hhvm,代碼行數:31,代碼來源:using_byrefs_to_undefined_variables.php


注:本文中的k函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。