foreach( array( $tagId, $postId ) as $i => & $value ) {
$stmt->bindParam( $i + 1, $value );
}
SELECT * FROM `banners` WHERE UNIX_TIMESTAMP(NOW()) % `rate_in_second` = 0
$arrayNode = json_decode( json_encode( $xmlObject ), true );
$arrayNode['@attributes'];
<?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 - наш идентификатор формы =)
?>
<?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
)
<?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'.
RewriteRule sitename/product_name_([0-9]+) sitename/products.php\?id=$1
<script src="js/file.js?<?=filemtime( 'js/file.js' )?>" />