newbie question - php parsing
newbie question - php parsing
am 22.07.2009 22:55:47 von Sebastiano Pomata
Hi all,
A little doubt caught me while I was writing this snippet of code for
a wordpress template:
I always thought that php was called only between the tags,
and I'm pretty sure that's right, while HTML code was simply wrote in
document as is, without further logic.
Now, I can't figure out how this snippet works: I mean, shouldn't HTML
code be simply put on document, as it is outside php invoke?
Effectively if the title of page is 'Home', the HTML part is totally
skipped.
Is the if construct that does all the magic inside?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: newbie question - php parsing
am 22.07.2009 23:01:33 von joao
You made a mistake in your code:
must be:
--
João Cândido de Souza Neto
SIENS SOLUÇÕES EM GESTÃO DE NEGÓCIOS
Fone: (0XX41) 3033-3636 - JS
www.siens.com.br
"Sebastiano Pomata" escreveu na mensagem
news:70fe20d60907221355m3fa49a75ua053d2f1b9aca055@mail.gmail .com...
> Hi all,
>
> A little doubt caught me while I was writing this snippet of code for
> a wordpress template:
>
>
>
>
>
> I always thought that php was called only between the tags,
> and I'm pretty sure that's right, while HTML code was simply wrote in
> document as is, without further logic.
> Now, I can't figure out how this snippet works: I mean, shouldn't HTML
> code be simply put on document, as it is outside php invoke?
> Effectively if the title of page is 'Home', the HTML part is totally
> skipped.
>
> Is the if construct that does all the magic inside?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: newbie question - php parsing
am 22.07.2009 23:24:00 von Shane Hill
--0016368324825fe9f5046f51fd71
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
2009/7/22 Jo=E3o C=E2ndido de Souza Neto
> You made a mistake in your code:
>
>
>
> must be:
>
>
=3D the_title(); ?>
also works.
-Shane
>
>
> --
> Jo=E3o C=E2ndido de Souza Neto
> SIENS SOLUÇÕES EM GEST=C3O DE NEG=D3CIOS
> Fone: (0XX41) 3033-3636 - JS
> www.siens.com.br
>
> "Sebastiano Pomata" escreveu na mensagem
> news:70fe20d60907221355m3fa49a75ua053d2f1b9aca055@mail.gmail .com...
> > Hi all,
> >
> > A little doubt caught me while I was writing this snippet of code for
> > a wordpress template:
> >
> >
> >
> >
> >
> > I always thought that php was called only between the tags,
> > and I'm pretty sure that's right, while HTML code was simply wrote in
> > document as is, without further logic.
> > Now, I can't figure out how this snippet works: I mean, shouldn't HTML
> > code be simply put on document, as it is outside php invoke?
> > Effectively if the title of page is 'Home', the HTML part is totally
> > skipped.
> >
> > Is the if construct that does all the magic inside?
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--0016368324825fe9f5046f51fd71--
Re: Re: newbie question - php parsing
am 22.07.2009 23:31:55 von 9el
--00163646d40ad88e2a046f521a3e
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Ted Turner -
"Sports is like a war without the killing."
2009/7/23 Shane Hill
> 2009/7/22 Jo=E3o C=E2ndido de Souza Neto
>
> > You made a mistake in your code:
> >
> >
> >
> > must be:
> >
> >
>
>
> =3D the_title(); ?>
Short tag and not recommended as its deprecated now, would be void at PHP
6.0
--00163646d40ad88e2a046f521a3e--
Re: Re: newbie question - php parsing
am 22.07.2009 23:46:06 von Martin Scotta
--001485e8ac6667460e046f524c5a
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
This is how I'd write this snippet
if ( 'Home' !== ( $title =3D the_title('','',FALSE)))
{
echo '
';
}
?>
On Wed, Jul 22, 2009 at 6:31 PM, Lenin wrote:
> Ted Turner
> -
> "Sports is like a war without the killing."
>
> 2009/7/23 Shane Hill
>
> > 2009/7/22 Jo=E3o C=E2ndido de Souza Neto
> >
> > > You made a mistake in your code:
> > >
> > >
> > >
> > > must be:
> > >
> > >
> >
> >
> > =3D the_title(); ?>
>
>
> Short tag and not recommended as its deprecated now, would be void at PHP
> 6.0
>
--=20
Martin Scotta
--001485e8ac6667460e046f524c5a--
Re: newbie question - php parsing
am 23.07.2009 00:17:02 von Shawn McKenzie
João Cândido de Souza Neto wrote:
> You made a mistake in your code:
>
>
>
> must be:
>
>
>
I haven't used worpress in a long time, but the the_title() function
might echo the title unless you pass the FALSE parameter, in which case
it just returns it.
--
Thanks!
-Shawn
http://www.spidean.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: newbie question - php parsing
am 23.07.2009 11:00:28 von Peter Ford
João Cândido de Souza Neto wrote:
> You made a mistake in your code:
>
>
>
> must be:
>
>
>
Not necessarily: what if you have
function the_title()
{
echo "Title";
}
for example...
In response to Sebastiano:
There would be not much point in using something like PHP if it ignored the "if"
statements in the code!
What effectively happens in a PHP source file is that all the bits outside of
the tags are treated like an "echo" statement (except that it handles
quotes and stuff nicely)
Your original code:
can be read like:
if (the_title('','',FALSE) != 'Home') {
echo '';
}
?>
You might even find a small (but probably really, really, really small)
performance improvement if you wrote it that way, especially if it was in some
kind of loop.
Note that I prefer to keep HTML separate from PHP as much as possible because it
helps me to read it and helps my editor check my syntax and HTML structure better...
--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: Re: newbie question - php parsing
am 23.07.2009 11:25:51 von Sebastiano Pomata
Thanks, it's now much more clear. I thought that html parts outside
php tags were just dumped to output, no matter of if-else statements
and other conditions. I was *definitely* wrong
2009/7/23 Peter Ford :
> In response to Sebastiano:
>
> There would be not much point in using something like PHP if it ignored t=
he "if"
> statements in the code!
> What effectively happens in a PHP source file is that all the bits outsid=
e of
> the tags are treated like an "echo" statement (except that it ha=
ndles
> quotes and stuff nicely)
>
> Your original code:
>
>
>
>
>
> can be read like:
>
>
> if (the_title('','',FALSE) !=3D 'Home') {
> =A0 =A0echo '';
> }
> ?>
>
> You might even find a small (but probably really, really, really small)
> performance improvement if you wrote it that way, especially if it was in=
some
> kind of loop.
> Note that I prefer to keep HTML separate from PHP as much as possible bec=
ause it
> helps me to read it and helps my editor check my syntax and HTML structur=
e better...
>
>
> --
> Peter Ford =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pho=
ne: 01580 893333
> Developer =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fax=
: =A0 01580 893399
> Justcroft International Ltd., Staplehurst, Kent
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php