--
This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professi...@googlegroups.com
To unsubscribe from this group, send email to Professional-P...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Professional-PHP
Depends on the purpose of the class.
Outputting HTML? Yes.
Anything else? No, and you'll die in a bright fire the burns away
every pound of flesh as you scream "My eyes, why did my eyes go
first!?"
--
Jack Timmons
@_Codeacula
Feel free to contact me on GTalk.
Kathy Lee Gifford will find you tonight to devour your soul.
> If you look at an old PHP project, you will likely notice very few templates
> and HTML is mixed with PHP throughout. The main reason almost everyone has
> moved to a pattern that separates HTML from PHP is maintainability. It's
> easier to fix something that isn't showing up correctly in your HTML by
> going through templates and mainly seeing HTML. Same goes for fixing
> something in PHP classes, it's cleaner and far better reading. Granted, some
> have taken it to the extreme, but that's a different question altogether ;)
> In the end, though, you are still mixing PHP and HTML, they are just in
> different files or some how separated by design until they merged together
> via include or return, etc.
Of course there's going to be HTML and PHP.
Should there be HTML in classes like the OP asked? I stand by my point.
I think you're going off in a different direction, though? I'm (and I
assume the OP) is strictly just talking about classes. Of course, I'm
also of the opinion there should be one class definition per file
(-maybe- two or three if the classes are all closely related, and I
mean like Siamese twins).
That is what I hate. I hate it.
Do you want to know why?
Because now you're going to have to escape every ' in that echo statement.
The first method is much more preferable.
That would explain the whole thing.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title><?=$page_title;?></title> </head> <body> <p>Hello</p> </body> </html>
They don't explain that this is likely in a .php file, not an .html file, but this is not a php class.
Maybe I'm misunderstanding?Example of why I hate using echos like that in PHP:
That's live code.
I shit thee not.
Cecil:
Do what you think is best. Honestly, the best way to do PHP is in a
way that gets the job done so you get paid.
Unless you're like me and have that annoying perfectionist voice
screaming in your head when you're half-assing it.
Everyone knows she's an undead temptress with regeneration powers to
make Wolverine seem like he bruises easily.
And no, there's nothing TECHNICALLY wrong with it. Just like there's
nothing technically wrong with building a mosque at ground zero. Or
there's nothing technically wrong with taking advantage of tax
loopholes to get out of paying more than you might otherwise. Or
there's nothing technically wrong about hitting that retarded teenager
in the head with a board. But people will still argue with you about
it. Especially in the tech community.
I do like the idea of the difference. Put PHP in your HTML, not HTML
in your PHP.
--
Jack Timmons
@_Codeacula
--
In the book, PHP and MySQL, the authors show code where HTML is inserted into their classes to build their headers and footers for each page throughout the sample web files.I read somewhere that this is not a good idea, but I am not sure why.
Can someone explain if it is good or not to mix in HTML with PHP classes?
Cecil
--
This group is managed and maintained by the development staff at 360 PSG. An enterprise application development company utilizing open-source technologies for todays small-to-medium size businesses.
For information or project assistance please visit :
http://www.360psg.com
You received this message because you are subscribed to the Google Groups "Professional PHP Developers" group.
To post to this group, send email to Professi...@googlegroups.com
To unsubscribe from this group, send email to Professional-P...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/Professional-PHP
On Sunday, August 29, 2010, Cecil Champenois <cecilch...@yahoo.com> wrote:
>
> Nick,
>
> I appreciate your taking the time to explain these things. I looked aroudn for a PHP class in a local college and couldn't find even one class on PHP/MySQL.
> Cecil
>
>
>
>
>
Do you mean shorttags?
And, if you do, do you know why you shouldn't use them?
> Jack Simmons told me in another thread that having a Wiki on your site
> is very important and I agree, specifically for these sorts of things
> so you can outline what values are available on a page and let them
> handle it.
It's Timmons. What, do I look like the brother of a gay fitness star?
Who is totally fabulous.
A wiki is the first step. There's a lot we should do as developers as
it relates to just administration crap.
> Just my 2 cents,
I want a refund.
Simmons. Seriously?
As a side note, I once knew a guy named Simmons. We were decent
friends, born on the same day, same year. He was a short, black man.
We got kicks out of that all the time.
On Mon, Aug 30, 2010 at 12:23 AM, Cecil Champenois
<cecilch...@yahoo.com> wrote:
> Nick,
>
> I appreciate your taking the time to explain these things. I looked aroudn
> for a PHP class in a local college and couldn't find even one class on
> PHP/MySQL.
You won't find it. Every college I've seen that -does- teach PHP is
still teaching it from back when PHP 4 came out.
--
Jack Timmons
@_Codeacula
Because short tags are an optional feature.
So, if you write all of your software using <?= and move to a new
server with it turned off, or update to a version of PHP that no
longer supports it, what choo gunna do?
That sort of deal.
--
Jack Timmons
@_Codeacula
Cheers!
That's not the point. The point is you aren't making portable code
when you do it that way. And do you always have control of your
server? What happens if you use short tags, and the server is switched
to a version that doesn't use it without you knowing? How much of your
business will be affected because you couldn't at most type a few
extra characters, and at least have a template to automatically put in
a full echo.
I use ec in my HTML layout. Four keypresses gets me <?php echo();?>.
Once you start down the path of the dark side, forever tainted will
your code be.
--
Jack Timmons
@_Codeacula
Even better, for those of you who freelance PHP:
You're writing software for your client using short tags. Everything's
working just dandy. The client tries it out and says it seems to be
working fine. He gives you the rest of your pay (you should be asking
for some up front, you know), and you give him the software.
But now he goes to put it up. But, what the hell, little is showing
up. Why are there all these gaps? So, not wanting to look like an
idiot to you (and possibly get charged more money for something that's
his fault), he calls his tech friend over. She apparently didn't have
time to do the project for him, but she can spot in a heartbeat what
the issue is.
Congratulations, you just lost future business for an untold amount.
Now, when the client speaks of you, he's going to talk about that
developer he hired who couldn't do the job right. Or about the
developer who might've turned the project in on time and budget, but
needed to support the software in ways that should have never needed
it.
Guess how often this happens?
Not to me. I mean for others using short tags.
--
Jack Timmons
@_Codeacula
There's so many things wrong with that statement.
First, never, -ever- insult your sysadmin. That's like being rude to
your waitress, except the sysadmin can do far worse than rub your New
York strip on the cook's buttocks.
Second, what are you going to do when this happens:
<?xml
> find another data-center that fits your needs. Nevertheless, this is just a
> very rare situation
Rare for you, perhaps. I've seen it frequently enough to warrant
notice beyond "Make it portable!"
My point is you can never know what's going to happen to your server,
and it's your duty to compensate for it. It's -your- fault for relying
on an optional feature of PHP.
> in conclusion, both <? and <?php are correct, and if
> you need to shorten out in some php like in this example:
"Correct" as in valid, I agree. But I'm arguing practice. One can
write software using sprintf correctly, but you're going to get yelled
at to use snprintf instead. And for good reason.
> <input name='name' type='text' value='<?=$name?>' /> then DO IT, it's far
> better to separate as much as possible the php code from the html code.
>
> oh yeah, another example:
>
> <div class='<?=$odd_even?>'><?=$the_value?></div>
>
> VS
>
> <div class='<?php echo $odd_even; ?>'><?php echo $the_value; ?></div>
The only thing I see wrong with that is I always encapsulate my echo's
in parenthesis.
> catch my drift?
If it ain't the Tokyo Drift, I ain't catchin' it.
I don't allow it in my department because I don't care to deal with
the possibility of someone turning it off, or a PHP update changing
the default from 0 to 1. If you want to, by all means it's technically
correct, and as a bureaucrat that's the best sort of correct you can
be. As a developer focused on portability and security, I'm going to
stick with my long tags.
--
Jack Timmons
@_Codeacula
Cheers!
What about just coding for portability and fighting The Good Fight?
That's what Three Dog would want you to do.
--
Jack Timmons
@_Codeacula
I'm am an apparent master of the double entendre.
My mom used to play Three Dog Night. I really liked what I heard.
But, the Three Dog I mentioned is in a whole 'nother realm.
http://fallout.wikia.com/wiki/Three_Dog
What's all this crazy question you're askin' me?
--
Jack Timmons
@_Codeacula
--
Jack Timmons
@_Codeacula
http://php.net/manual/en/language.basic-syntax.phpmode.php
The latter two being, IM(not totally)HO, totally pointless, useless,
and seriously asking to be removed.
There might be a point. And there might be a use. But I've never once
come across it, and I don't think I care to.
--
Jack Timmons
@_Codeacula
--