Jump to content


Photo

[solved] php inside html stop working?


  • This topic is locked This topic is locked
11 replies to this topic

#1 Marxx

Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 03 December 2006 - 06:42 PM

Hi..

Shortly:

inside html i use some php ex.

<div class="sloga"><img src="<?=$SITEADDR?>/img/sloga.gif" width="700px" height="100px"></div>

u see that
<?=$SITEADDR?>


well, that doesn't work anymore.. I used to use EASYphp but i change that to WAMP and after that those things doesn't work anymore.. Why??

output in browser is exactly what is in that my example.. :P

#2 Hayden

Hayden

    P2L Jedi

  • Members
  • PipPipPip
  • 717 posts
  • Gender:Male
  • Location:Texas

Posted 03 December 2006 - 07:44 PM

assuming your filename ends with the .php extension or you have the appropriate application handlers in place...

same thing happened to me when I switched to PHP 5

change
<div class="sloga"><img src="<?=$SITEADDR?>/img/sloga.gif" width="700px" height="100px"></div>

to
<div class="sloga"><img src="<?php echo $SITEADDR; ?>/img/sloga.gif" width="700px" height="100px"></div>

settings in the PHP.INI are not setup to allow the <?=$SITEADDR?> but from what I have seen it is better to do it the latter anyhow.

#3 Marxx

Marxx

    Young Padawan

  • Members
  • Pip
  • 116 posts
  • Gender:Male
  • Location:Finland

Posted 04 December 2006 - 07:07 AM

Oh.. Well that works alright! Thanks

I just liked that "old" way to do it.. :whoosh[1]:

#4 NGPixel

NGPixel

    Senior Programmer

  • P2L Staff
  • PipPipPipPip
  • 1,410 posts
  • Gender:Male
  • Location:Montreal, Canada
  • Interests:Web Design : Coding : Animation

Posted 04 December 2006 - 10:52 AM




#5 Matthew.

Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 04 December 2006 - 11:40 AM

rc69 explained this in a previous topic. You need to change some settings in php.ini for <?= to work :whoosh[1]:

If i find the topic, ill post it :D

- Adam :)


http://www.pixel2lif...p...st&p=184589
http://www.pixel2lif...p...st&p=184595

#6 Av-

Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,972 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 04 December 2006 - 03:24 PM

Why not just use print instead, works on any machine with any version.

#7 Matthew.

Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 04 December 2006 - 03:36 PM

Why not just use print instead, works on any machine with any version.


So does echo. It's the shortcut in question that is causing the problem as it depends on a server setting.

Since you brought it up, depending on the amount of data being outputted print can be around half as slow as echo.

#8 Av-

Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,972 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 04 December 2006 - 05:33 PM

ya well, print or echo pretty much the same.

#9 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 05 December 2006 - 01:27 AM

You can ready php.net's faq about it, but to sum up:
print and echo are not the same. They are both language constructs, true. But print returns a value of "1" all of the time, echo doesn't return anything. Because of that, echo tends to run a little bit faster.

So, whether or not you use print or echo doesn't matter (unless you're using heredoc syntax, but that is a different subject), dictating one over the other is like choosing between butter and margarine. One simply tastes better, and one is healthier...

#10 influct

influct

    Young Padawan

  • Members
  • Pip
  • 63 posts

Posted 07 December 2006 - 06:58 AM

I had the same problem:)
just click your wamp icon in your system tray, select php settings and at the top you'll see short open tag, click once to enable.
Problem solved:D

#11 derek.sullivan

derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 343 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 19 December 2006 - 01:53 PM

What you did wrong was in your <?=whatever?> you did not add an ; ... this is requried to show where you want your code to stop otherwise, it wont work right.


Hi..

Shortly:

inside html i use some php ex.

<div class="sloga"><img src="<?=$SITEADDR?>/img/sloga.gif" width="700px" height="100px"></div>

u see that
<?=$SITEADDR?>


well, that doesn't work anymore.. I used to use EASYphp but i change that to WAMP and after that those things doesn't work anymore.. Why??

output in browser is exactly what is in that my example.. :closedeyes:



#12 rc69

rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 19 December 2006 - 10:50 PM

Derek, this topic has been solved for close to a month. And you're slightly wrong, a closing php tag implies a semi-colon.
Ref: Instruction Seperation




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users