/    Sign up×
Community /Pin to ProfileBookmark

Variables inside an embedded for loop

Meh. I just forgot to echo it.

This is inside a php document with html in it.
This doesn’t display

[CODE]
<? for($i = 1; $i <= $numof_pages; $i++) : ?>
<? $i ?>
<? endfor; ?>
[/CODE]

This displays

[CODE]
<? for($i = 1; $i <= $numof_pages; $i++) : ?>
Sample text
<? endfor; ?>
[/CODE]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 05.2012 — [code=php]
<? echo $i; ?>
[/code]

(Although I recommend always using the full "<?php" tag, as short_open_tags is not guaranteed to be enabled in all environments, whereas the full tags are.)
Copy linkTweet thisAlerts:
@Jonas_authorJul 05.2012 — Ok. That's a very good tip. Thank you.
×

Success!

Help @Jonas_ spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...