当前位置: 首页>>代码示例>>PHP>>正文


PHP a::json方法代码示例

本文整理汇总了PHP中a::json方法的典型用法代码示例。如果您正苦于以下问题:PHP a::json方法的具体用法?PHP a::json怎么用?PHP a::json使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在a的用法示例。


在下文中一共展示了a::json方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: set

 /**
  * Set a new cookie
  * 
  * <code>
  * 
  * cookie::set('mycookie', 'hello', 60);
  * // expires in 1 hour
  * 
  * </code>
  * 
  * @param  string  $key The name of the cookie
  * @param  string  $value The cookie content
  * @param  int     $lifetime The number of minutes until the cookie expires
  * @param  string  $path The path on the server to set the cookie for
  * @param  string  $domain the domain 
  * @param  boolean $secure only sets the cookie over https
  * @param  boolean $httpOnly avoids the cookie to be accessed via javascript
  * @return boolean true: the cookie has been created, false: cookie creation failed
  */
 public static function set($key, $value, $lifetime = 0, $path = '/', $domain = null, $secure = false, $httpOnly = true)
 {
     // convert array values to json
     if (is_array($value)) {
         $value = a::json($value);
     }
     // hash the value
     $value = static::hash($value) . '+' . $value;
     // store that thing in the cookie global
     $_COOKIE[$key] = $value;
     // store the cookie
     return setcookie($key, $value, static::lifetime($lifetime), $path, $domain, $secure, $httpOnly);
 }
开发者ID:kgchoy,项目名称:main-portfolio-website,代码行数:32,代码来源:cookie.php

示例2: set

 /**
  * Set a new cookie
  * 
  * <code>
  * 
  * cookie::set('mycookie', 'hello', 60);
  * // expires in 1 hour
  * 
  * </code>
  * 
  * @param  string  $key The name of the cookie
  * @param  string  $value The cookie content
  * @param  int     $expires The number of minutes until the cookie expires
  * @param  string  $path The path on the server to set the cookie for
  * @param  string  $domain the domain 
  * @param  boolean $secure only sets the cookie over https
  * @return boolean true: the cookie has been created, false: cookie creation failed
  */
 public static function set($key, $value, $expires = 0, $path = '/', $domain = null, $secure = false)
 {
     // convert minutes to seconds
     if ($expires > 0) {
         $expires = time() + $expires * 60;
     }
     // convert array values to json
     if (is_array($value)) {
         $value = a::json($value);
     }
     // hash the value
     $value = static::hash($value) . '+' . $value;
     // store that thing in the cookie global
     $_COOKIE[$key] = $value;
     // store the cookie
     return setcookie($key, $value, $expires, $path, $domain, $secure);
 }
开发者ID:williampan,项目名称:w,代码行数:35,代码来源:cookie.php

示例3: write

 /**
  * Creates a new file
  * 
  * @param  string  $file The path for the new file
  * @param  mixed   $content Either a string or an array. Arrays will be converted to JSON. 
  * @param  boolean $append true: append the content to an exisiting file if available. false: overwrite. 
  * @return boolean 
  */
 static function write($file, $content, $append = false)
 {
     if (is_array($content)) {
         $content = a::json($content);
     }
     $mode = $append ? FILE_APPEND : false;
     $write = @file_put_contents($file, $content, $mode);
     @chmod($file, 0666);
     return $write;
 }
开发者ID:sdvig,项目名称:kirbycms,代码行数:18,代码来源:kirby.php

示例4: testJson

 public function testJson()
 {
     $this->assertEquals(json_encode($this->user), a::json($this->user));
 }
开发者ID:LucasFyl,项目名称:korakia,代码行数:4,代码来源:ATest.php

示例5: Chart

    ?>
	<script>
	var ctx = document.getElementById("myChart").getContext("2d");
	var data = {
		labels: <?php 
    echo a::json(array_keys($history));
    ?>
,
		datasets: [
			{
				label: "Kirby Stats",
				fillColor: "rgba(141, 174, 40, 0.3)",
				strokeColor: "rgba(141, 174, 40, 0.8)",
				pointColor: "rgba(220,220,220,1)",
				pointStrokeColor: "#fff",
				pointHighlightFill: "#fff",
				pointHighlightStroke: "rgba(220,220,220,1)",
				data: <?php 
    echo a::json(array_values($history));
    ?>
,
			},
		]
	};
	var myLineChart = new Chart(ctx).Line(data, {
		'bezierCurve': false,
		'responsive': true,
	});
	</script>
<?php 
}
开发者ID:tweh,项目名称:kirby-stats,代码行数:31,代码来源:template.php

示例6: site

 //if page is accessed thorugh ajax
 if (r::ajax()) {
     //store sanitized $_POST variables
     $currentTestData = r::postData(array('test', 'user', 'data'));
     //get logged user (if any)
     if ($user = Auth::loggedUser()) {
         //get user's session page
         $userSession = site()->find(implode(DS, array(c::get('sessions.folder'), $user->session())));
         //istantiate testSession object
         $tSession = new testSession($userSession, $user->username());
         //get user's current session status
         $userSessionStatus = $user->status();
         //if ajaxed $currentTestData equals user's current session status
         if (str::lower($currentTestData['test']) == str::lower($userSessionStatus)) {
             //if it was possitble to update user's results file (by appending $currentTestData)
             if (f::append($tSession->getUserResultsFile(), PHP_EOL . a::json($currentTestData))) {
                 //set updated user's session status to next avalibale test
                 $updatedStatus = $tSession->getNextTest($currentTestData['test']);
                 //if there aren't tests available, set user's session statuts to completed session
                 if (!$updatedStatus) {
                     $updatedStatus = c::get('session.status.completed');
                 }
                 //update user's session status to next avalibale test
                 $user->update(array('status' => $updatedStatus));
                 //return to tests page
                 $url = $pages->find(c::get('tests.folder'))->url();
             }
         }
     }
 } else {
     //go to errorPage, since page wasn't accessed through ajax
开发者ID:alkaest2002,项目名称:risky2,代码行数:31,代码来源:cerebro.php

示例7: sendWithPostmark

 private function sendWithPostmark()
 {
     if (!$this->options['postmark.key']) {
         return array('status' => 'error', 'msg' => l::get('email.error.invalid.key', 'Invalid API key'));
     }
     // reset the api key if we are in test mode
     if ($this->options['postmark.test']) {
         $this->options['postmark.key'] = 'POSTMARK_API_TEST';
     }
     $url = 'http://api.postmarkapp.com/email';
     $headers = array('Accept: application/json', 'Content-Type: application/json', 'X-Postmark-Server-Token: ' . $this->options['postmark.key']);
     $data = array('From' => $this->options['from'], 'To' => $this->options['to'], 'ReplyTo' => $this->options['replyto'], 'Subject' => $this->options['subject'], 'TextBody' => $this->options['body']);
     $response = $this->post($url, a::json($data), array('headers' => $headers));
     $code = @$response['http_code'];
     if ($code != 200) {
         return array('status' => 'error', 'msg' => l::get('email.error', 'The mail could not be sent!'), 'response' => $response);
     }
     return array('status' => 'success', 'msg' => l::get('email.success', 'The mail has been sent'), 'response' => $response);
 }
开发者ID:scheibome,项目名称:kirbycms-extensions,代码行数:19,代码来源:email.php

示例8: testArrayJson

 function testArrayJson()
 {
     $this->assertEqual(a::json($this->arr), '{"cat":"miao","dog":"wuff","bird":"tweet"}');
 }
开发者ID:o-github-o,项目名称:jQuery-Ajax-Upload,代码行数:4,代码来源:array.php

示例9: function

					return YAML.stringify(this.values);
				},
				section: function (){
					return message
				},
				records: function (){
					return this.values
				}
			},
			// watch:{

			// },
			methods:{
				addEntrie: function (v_index){
					newEntrie =  <?php 
echo a::json($blueprint);
?>
;
					this.values.push(newEntrie);
				},
				editEntrie: function (v_index){

					if (this.editedEntries[v_index]) {
						Vue.set(this.editedEntries, v_index, 0);
					}else{
						Vue.set(this.editedEntries, v_index, 1);
					};

					console.log(this.editedEntries);
				},
				removeEntrie: function (index){
开发者ID:idrisyangui,项目名称:kirby-field-repeater,代码行数:31,代码来源:template.php


注:本文中的a::json方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。