Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 198ab4a

Browse filesBrowse files
dr-matt-smithwouterj
authored andcommitted
replace occurrences of <?php echo with <?=
<?= now a first class citizen of PHP code <?= nicely equates to {{ }} in Twig - i.e. output string casting of expression leaving <?php logic blocks to equate to Twig {% .. matt ..
1 parent ea9574c commit 198ab4a
Copy full SHA for 198ab4a

File tree

Expand file treeCollapse file tree

1 file changed

+15
-15
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-15
lines changed

‎book/from_flat_php_to_symfony2.rst

Copy file name to clipboardExpand all lines: book/from_flat_php_to_symfony2.rst
+15-15Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ persisted to the database. Writing in flat PHP is quick and dirty:
4444
<ul>
4545
<?php while ($row = $result->fetch(PDO::FETCH_ASSOC)): ?>
4646
<li>
47-
<a href="/show.php?id=<?php echo $row['id'] ?>">
48-
<?php echo $row['title'] ?>
47+
<a href="/show.php?id=<?= $row['id'] ?>">
48+
<?= $row['title'] ?>
4949
</a>
5050
</li>
5151
<?php endwhile ?>
@@ -113,8 +113,8 @@ is primarily an HTML file that uses a template-like PHP syntax:
113113
<ul>
114114
<?php foreach ($posts as $post): ?>
115115
<li>
116-
<a href="/show.php?id=<?php echo $post['id'] ?>">
117-
<?php echo $post['title'] ?>
116+
<a href="/show.php?id=<?= $post['id'] ?>">
117+
<?= $post['title'] ?>
118118
</a>
119119
</li>
120120
<?php endforeach ?>
@@ -205,10 +205,10 @@ that by creating a new ``layout.php`` file:
205205
<!DOCTYPE html>
206206
<html>
207207
<head>
208-
<title><?php echo $title ?></title>
208+
<title><?= $title ?></title>
209209
</head>
210210
<body>
211-
<?php echo $content ?>
211+
<?= $content ?>
212212
</body>
213213
</html>
214214

@@ -224,8 +224,8 @@ the layout:
224224
<ul>
225225
<?php foreach ($posts as $post): ?>
226226
<li>
227-
<a href="/show.php?id=<?php echo $post['id'] ?>">
228-
<?php echo $post['title'] ?>
227+
<a href="/show.php?id=<?= $post['id'] ?>">
228+
<?= $post['title'] ?>
229229
</a>
230230
</li>
231231
<?php endforeach ?>
@@ -284,11 +284,11 @@ the individual blog post:
284284
<?php $title = $post['title'] ?>
285285

286286
<?php ob_start() ?>
287-
<h1><?php echo $post['title'] ?></h1>
287+
<h1><?= $post['title'] ?></h1>
288288

289-
<div class="date"><?php echo $post['created_at'] ?></div>
289+
<div class="date"><?= $post['created_at'] ?></div>
290290
<div class="body">
291-
<?php echo $post['body'] ?>
291+
<?= $post['body'] ?>
292292
</div>
293293
<?php $content = ob_get_clean() ?>
294294

@@ -575,11 +575,11 @@ database and the Templating component to render a template and return a
575575
<ul>
576576
<?php foreach ($posts as $post): ?>
577577
<li>
578-
<a href="<?php echo $view['router']->generate(
578+
<a href="<?= $view['router']->generate(
579579
'blog_show',
580580
array('id' => $post->getId())
581581
) ?>">
582-
<?php echo $post->getTitle() ?>
582+
<?= $post->getTitle() ?>
583583
</a>
584584
</li>
585585
<?php endforeach ?>
@@ -593,13 +593,13 @@ The layout is nearly identical:
593593
<!DOCTYPE html>
594594
<html>
595595
<head>
596-
<title><?php echo $view['slots']->output(
596+
<title><?= $view['slots']->output(
597597
'title',
598598
'Default title'
599599
) ?></title>
600600
</head>
601601
<body>
602-
<?php echo $view['slots']->output('_content') ?>
602+
<?= $view['slots']->output('_content') ?>
603603
</body>
604604
</html>
605605

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.