Skip to content

Instantly share code, notes, and snippets.

@ncer
Last active June 2, 2018 13:38
Show Gist options
  • Save ncer/8e52081d837af718488493e99b737a43 to your computer and use it in GitHub Desktop.
Save ncer/8e52081d837af718488493e99b737a43 to your computer and use it in GitHub Desktop.
PHP helpers
<? for ($i = 1; $i <= 5; $i++) {?>
<p><?= $i ?></p>
<?}?>
<? $items = [
1 => [
'title' => 'Title1',
'text' => 'Text1'
],
[
'title' => 'Title2',
'text' => 'Text2'
],
[
'title' => 'Title3',
'text' => 'Text3'
]
];?>
<? foreach( $items as $i => $item ) {?>
<article id="<?= $i ?>">
<h3><?= $item['title'] ?></h3>
<p><?= $item['text'] ?></p>
</article>
<?}?>
<? $items = [
1 => 'Item1',
'Item2',
'Item3'
];?>
<? foreach( $items as $i => $item ) {?>
<article id="<?= $i ?>">
<h3><?= $item ?></h3>
</article>
<?};?>
<? $items = [
1 => [
'image' => 'http://placehold.it/350x150',
'title' => 'Title1',
'text' => 'Text1'
],
[
'title' => 'Title2',
'text' => 'Text2'
],
[
'title' => 'Title3',
'text' => 'Text3'
]
];?>
<? foreach( $items as $i => $item ) {?>
<article id="<?= $i ?>">
<h3><?= $item['title'] ?></h3>
<? if( isset($item['image']) ) {?>
<img src="<?= $item['image'] ?>" alt="">
<?};?>
<p><?= $item['text'] ?></p>
</article>
<?}?>
<base href="<? echo "http://".$_SERVER['SERVER_NAME'].dirname($_SERVER["REQUEST_URI"].'?'); ?>" />
2006 - <?= date('Y') ?>
<? if (true) : ?>
<h1>TRUE</h1>
<? else : ?>
<h1>FALSE</h1>
<? endif ?>
<? echo file_get_contents('file.svg') ?>
<?
$resSuffix = '';
if (\Wf::$isLiveServer) {
$resSuffix = '.min';
}
?>
<link href="templates/build/css/styles<?=$resSuffix?>.css?<?= @filemtime(WWW_DIR . "templates/build/css/styles{$resSuffix}.css") ?>" rel="stylesheet" />
<script src="templates/build/js/scripts<?=$resSuffix?>.js?<?= @filemtime(WWW_DIR . "templates/build/js/scripts{$resSuffix}.js") ?>"></script>
@ponich
Copy link

ponich commented May 23, 2018

You need read PSR-0,1,2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment