<?php
define( 'echo', '3.14' );
echo echo;
<?php
echo pi(); // 3.1415926535898
echo M_PI; // 3.1415926535898
<form action="index.php" method="post">
<input type="text" name="user_name" />
<input type="submit" value="Отправить" />
<input type="hidden" name="form_id" value="1" />
</form>
<form action="index.php" method="post">
<input type="text" name="user_name" />
<input type="submit" value="Отправить" />
<input type="hidden" name="form_id" value="2" />
</form>
<form action="index.php" method="post">
<input type="text" name="user_name" />
<input type="submit" value="Отправить" />
<input type="hidden" name="form_id" value="3" />
</form>
<?php
$formId = isset( $_POST['form_id'] ) ? $_POST['form_id'] : 1;
// $formId - наш идентификатор формы =)
?>
$('a.target_link').click(function() {
if ( this.href != location.href ) {
if( typeof window.history.pushState != undefined ) {
history.pushState( null, null, this.href );
}
$.ajax({
method : 'get',
url : this.href,
success : function( response ){
$('#content').html( response );
}
});
}
return false;
});
<?php
class MyPage {
static public function show() {
print __METHOD__ . ' Args: ' . print_r( func_get_args(), true );
}
}
class Router {
static public $page = 'MyPage';
}
// способ 1
$page = Router::$page;
$page::show();
// способ 2
call_user_func_array( array( Router::$page, 'show' ), array(
'something', 'args'
) );
MyPage::show Args: Array
(
)
MyPage::show Args: Array
(
[0] => something
[1] => args
)
select * from `orders` where `sum` > 500
<?php
class MyClass {
private
$data = array();
public function __construct() {
$this->data = array(
'test' => 'data test',
'test2' => 'data test 2'
);
}
public function __call( $method = null, $data = null ){
$type = strtolower( substr( $method, 0, 2 ) );
switch( type ) {
case 'set': {
$this->data[strtolower( substr( $method, 3 ) )] = $data;
break;
}
case 'get': {
$key = strtolower( substr( $method, 3 ) );
return isset( $this->data[$key] ) ? $this->data[$key] : null;
break;
}
}
return null;
}
}
$object = new MyClass();
print $object->getTest(); // data test
print $object->getTest2(); // data test 2
$object->setFoo( 'bar' );
print $object->getFoo(); // bar
print $object->getFoo2(); // null
Содержимое заголовка Accept-Language: из текущего запроса, если он есть. Например: 'en'.
$(document).ready(function(){
if (window.location.hash == '#w100' ) {
$(".contentwidthr").css("width","100% !important");
};
});
RewriteRule sitename/product_name_([0-9]+) sitename/products.php\?id=$1
<script src="js/file.js?<?=filemtime( 'js/file.js' )?>" />