Can't escape PHP within a function to get plain HTML

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
denisdee
Forum Newbie
Posts: 2
Joined: Thu Aug 27, 2009 11:41 am

Can't escape PHP within a function to get plain HTML

Post by denisdee »

Hi there,

Got a little issue with PHP 5.3.0
When I enter this code :

Code: Select all

<?php 
    function my_function() {
?>
My function was called
<?php
  }
?>
nothing happens. Don't get anything in my browser (tried in IE and Firefox). The text doesn't show and I don't get any error (although PHP is configured to display error).
Strangely enough, I ran some code that I got from a tutorial in my browser with the same type of functions and it worked just fine.
I'm a bit confused.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Can't escape PHP within a function to get plain HTML

Post by jackpf »

Works for me.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Can't escape PHP within a function to get plain HTML

Post by requinix »

You do realize you have to call the function for it to do anything, right?

Code: Select all

<?php
    function my_function() {
?>
My function was called
<?php
  }
 
my_function();
?>
denisdee
Forum Newbie
Posts: 2
Joined: Thu Aug 27, 2009 11:41 am

Re: Can't escape PHP within a function to get plain HTML

Post by denisdee »

I do realize it now. :banghead: I was so sure that there was a problem (had some issues before that and had to reinstall php) that I thought that there had to be something wrong when there hadn't.

Thanks anyway.
Post Reply