( new class( "Hello" )
{
public function __construct( $str )
{
echo( $str );
}
});
// Можно без скобок :
new class( "Hello" )
{
public function __construct( $str )
{
echo( $str );
}
};
// Можно с переменной:
$cl = new class( "Hello" ){
public function __construct( $str )
{
echo( $str );
}
};
var_dump( $cl );
...
require_once($_SERVER['DOCUMENT_ROOT'].'\Extension\phpexcel\PHPExcel\IOFactory.php');
$excel = \PHPExcel_IOFactory::load("$temp_dir/$file");
$arr = $excel->getActiveSheet()->toArray(null,true,true,true);
foreach ($arr as $key => $value) {
$tab_num = $value["B"];
...
$num = 128.40;
$arr = explode(".", $num );
list( $arub, $acop ) = $arr ;
$acop *= 10;
echo "$arub : $acop";
$num = 128.40;
$arub = floor( $num );
$acop = floor( ( $num - $arub ) * 100 );
echo "$arub : $acop";
class Model
{
...
private title;
private contents;
...
public function setTitle( $title )
{
$object->title = $title;
}
public function setContent( $contents )
{
$object->contents = $contents;
}
public function save()
{
...
}
}
...
$model = new Model();
$model->setTitle( "Заголовок" );
$model->setContent( "Описание" );
$model->save();
...
...
0 0 * * * date >> /var/phppass.txt
0 0 * * * date >> php /var/script.php
...
<?php
// Получение сплошного списка
function get_cat()
{
global $pdo;
$cat_arr = [];
try
{
$query = "SELECT ID, PID, NAME FROM `catalog` WHERE 1";
$stmt = $pdo->prepare( $query );
$stmt->execute();
}
catch (PDOException $e)
{
die("Error in :".__FILE__." file, at ".__LINE__." line. Can't get data : " . $e->getMessage());
}
while( $row = $stmt->fetch(PDO::FETCH_ASSOC ) )
$cat_arr[$row['ID']] = $row;
return $cat_arr;
}
// Построение дерева
function tree_map( $dataset )
{
$tree = [];
foreach ($dataset as $id=>&$node)
if (!$node['PID'])
$tree[$id] = &$node;
else
$dataset[$node['PID']]['childs'][$id] = &$node;
return $tree;
}
$dataset = get_cat();
$dataset = tree_map( $dataset );
<?php
function debug( $arr )
{
$str = print_r($arr, true);
echo '<pre>'.$str.'</pre>';
}
<?php
$id = []
$id[] = '1';
$id[] = '2';
$id[] = '3';
$id[] = '4';
$posts = R::findOne('posts', 'id', $id );
echo $posts->head, '<br>';
echo $posts->desc;
<?php
$posts = R::findOne('posts', 'id', [ '1', '2', '3', '4' ] );
или
$posts = R::findOne('posts', 'id', [ 1, 2, 3, 4 ] );
echo $posts->head, '<br>';
echo $posts->desc;