Things in php that made you go WHOA!
Moderator: General Moderators
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
I'll second that -- especially a controller architecture. I have found that a good clean controller implementation makes everything else fall neatly into place. For me, Models and View are just busy-work.MrPotatoes wrote:once i learned how to use the MVC design pattern everything opened up for me.
(#10850)
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
ew really? you code everything into your Controller?
i've been doing pusedo MVC's for awhile now. i just didn't know there was a real pattern that was already definded and used and documented. so it came pretty easilly to me. and man is my coding so much cleaner and nicer. i've done basically a front controller and a whol bunch of models and such. now i've got everything so split up it's sexy.
but i still put everything into the model and the controller really is justa switch statement that checks for user input in the views
honestly tho, my code is really clean and really nice. this is the best code i've writen in the longes time and i'm anal retentive about good clean code. ask my friends, i'm known for it lmao!
i've been doing pusedo MVC's for awhile now. i just didn't know there was a real pattern that was already definded and used and documented. so it came pretty easilly to me. and man is my coding so much cleaner and nicer. i've done basically a front controller and a whol bunch of models and such. now i've got everything so split up it's sexy.
but i still put everything into the model and the controller really is justa switch statement that checks for user input in the views
honestly tho, my code is really clean and really nice. this is the best code i've writen in the longes time and i'm anal retentive about good clean code. ask my friends, i'm known for it lmao!
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
- Buddha443556
- Forum Regular
- Posts: 873
- Joined: Fri Mar 19, 2004 1:51 pm
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
a pattern is something that is applicatble. if it has been started somewhere else fine but it doesn't mean that it's not PHP because of that.d11wtq wrote:Hang on a minute. MVC? AJAX? These things aren't really PHP that made you go WHOA, these are more general fields that apply to other languagesThinking of things just in PHP that make you go WHOA is pretty tough actually. I sadly can't think of anything much more than what's already been said
and no, it didn't really make me go WHOA like my loader class did but it did make me thing how awesome it is to have a name and more guidelines for something that i've been doing quite literally for years
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
- MrPotatoes
- Forum Regular
- Posts: 617
- Joined: Wed May 24, 2006 6:42 am
i miss it and i don't miss it.Maugrim_The_Reaper wrote:Thinking about where I came from, C++/Java, saying goodbye to int,long,double,float,byte,char,etc was actually kind of neat... I did miss type hinting and access control though - seemed a bit lazy at the time.
i love thier string stuff. but i wish we had pointers and control over loading. w/o having to actually change the way that it's put onto the server. well, pointers if you want them but don't need them kind of option. that would be awesome. cuz PHP is fast as hell as it is and with pointers it would only add to it but you don't actually need them if you don't want them
that would be my perfect web language
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I doubt PHP will ever include pointers. I'm not sure there's even a need for itMrPotatoes wrote:but i wish we had pointers and control over loading. w/o having to actually change the way that it's put onto the server. well, pointers if you want them but don't need them kind of option.
Namespaces I would like. Especially for creating libraries which need to be integrated into any other code namespaces give you a nice clean separation.
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Seems everyone missed the boat... 
I thought this was PHP functionality only...?
Anyways...PHP has tons of quirks which have made me go whoa or &@#^&@$(*&
PHP4:
1) Objects instances are not unique
If you compare (using == or ===) two objects of the same class with the same data they are always the same...this is because PHP doesn't support instances perse in PHP4 - this is corrected in PHP5
I encountered this problem while working on a DOM implementaiton...as it is possible to have a Node object initialized with the same data...
2) Class names are not preserved *exactly* as written but converted to lowercase for whatever reason.
If your framework code relies on your written convention...this can bite you in the a$$
Variable variables caught me by surprise when I first started as I typo-ed a variable wrong and couldn't figure out WTF was going wrong...
PHP Heredoc interesting...albeit hardly useful...at least once I got comfortable to using template engines anyways
Value and Value and Type Comparisons Using === or == was confusing when I started...until I got use to using a loosely typed language...
The ease of use of PHP was frustrating...it introduced a whole new set of problems that a compiler would typically catch...
Mostly...the paradigm shift of desktop application developement to web application development is what was most difficult for me...
Most Windows desktop applications don't require user login, etc...at least not on Win16/32...because of the lack of networks, distributed environments, etc on older Windows desktops...I also never paid much attention to security...filtering data, etc...
Later on, when I started with COM I began to pay attention to things like buffer overflows, etc...
SQL was probably the biggest hurdle for me...as I always start from the bottom and work up when I learn something...I couldn't figure out for the life of me how the hell SQL worked...
Understood it's concept...but needed to understand the underlying engine before I accepted it's use...
Were tables files or were tables stored inside a single database file...were some quqestions I had to ask...until I switched to PHP I wrote all data access by hand
That was an embarissing moment
Using PHP CLI is interesting if you require some advanced file search and filter...
Last but not least...PHP extensions are a real joy...especially those pointed out to me by Feyd...
The runkit extension lets me emulate Windows hooks...which are very powerful
If you can capture when a function, etc is called, you can do many cool things, such as:
1) Automatically profile your functions without having to enter start and stop code...
2) Generate a call graph of executed functions/methods
3) Disable functions, etc...
http://pecl.php.net/package/runkit
There are many little caveats of PHP which throw me off when I try something that C++ did nicely...but thats a whole different story
Cheers
I thought this was PHP functionality only...?
Anyways...PHP has tons of quirks which have made me go whoa or &@#^&@$(*&
PHP4:
1) Objects instances are not unique
If you compare (using == or ===) two objects of the same class with the same data they are always the same...this is because PHP doesn't support instances perse in PHP4 - this is corrected in PHP5
I encountered this problem while working on a DOM implementaiton...as it is possible to have a Node object initialized with the same data...
2) Class names are not preserved *exactly* as written but converted to lowercase for whatever reason.
If your framework code relies on your written convention...this can bite you in the a$$
Variable variables caught me by surprise when I first started as I typo-ed a variable wrong and couldn't figure out WTF was going wrong...
PHP Heredoc interesting...albeit hardly useful...at least once I got comfortable to using template engines anyways
Value and Value and Type Comparisons Using === or == was confusing when I started...until I got use to using a loosely typed language...
The ease of use of PHP was frustrating...it introduced a whole new set of problems that a compiler would typically catch...
Mostly...the paradigm shift of desktop application developement to web application development is what was most difficult for me...
Most Windows desktop applications don't require user login, etc...at least not on Win16/32...because of the lack of networks, distributed environments, etc on older Windows desktops...I also never paid much attention to security...filtering data, etc...
Later on, when I started with COM I began to pay attention to things like buffer overflows, etc...
SQL was probably the biggest hurdle for me...as I always start from the bottom and work up when I learn something...I couldn't figure out for the life of me how the hell SQL worked...
Understood it's concept...but needed to understand the underlying engine before I accepted it's use...
Were tables files or were tables stored inside a single database file...were some quqestions I had to ask...until I switched to PHP I wrote all data access by hand
That was an embarissing moment
Using PHP CLI is interesting if you require some advanced file search and filter...
Last but not least...PHP extensions are a real joy...especially those pointed out to me by Feyd...
The runkit extension lets me emulate Windows hooks...which are very powerful
If you can capture when a function, etc is called, you can do many cool things, such as:
1) Automatically profile your functions without having to enter start and stop code...
2) Generate a call graph of executed functions/methods
3) Disable functions, etc...
http://pecl.php.net/package/runkit
There are many little caveats of PHP which throw me off when I try something that C++ did nicely...but thats a whole different story
Cheers
Hockey wrote:PHP Heredoc interesting...albeit hardly useful...at least once I got comfortable to using template engines anyways
I always use HEREDOC syntax, especially for SQL statements. Look at the difference:
Code: Select all
$sql= 'SELECT b.prodID, b.catID, b.title, b.market_price, b.sale_price, c.category, c.page FROM books AS b INNER JOIN categories AS c USING (catID) WHERE b.ISBN = \'' .$ISBN. '\'';Code: Select all
$sql= <<< END
SELECT
b.prodID
, b.catID
, b.title
, b.market_price
, b.sale_price
, c.category
, c.page
FROM books AS b
INNER JOIN categories AS c
USING (catID)
WHERE b.ISBN = '{$ISBN}'
END;When I first saw this, it definitely made a 'whoa' impression.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Funny thing, when I learned that you can span lines inside of strings (without concatenating) I found that SQL queries became a lot easier to read.bdlang wrote:Hockey wrote:PHP Heredoc interesting...albeit hardly useful...at least once I got comfortable to using template engines anyways![]()
I always use HEREDOC syntax, especially for SQL statements. Look at the difference:compared toCode: Select all
$sql= 'SELECT b.prodID, b.catID, b.title, b.market_price, b.sale_price, c.category, c.page FROM books AS b INNER JOIN categories AS c USING (catID) WHERE b.ISBN = \'' .$ISBN. '\'';The ability to add / remove elements of the statement, enhanced readability is so much better; although you could use the concatenation operator to spread it across multiple lines, this way is alot easier and less code.Code: Select all
$sql= <<< END SELECT b.prodID , b.catID , b.title , b.market_price , b.sale_price , c.category , c.page FROM books AS b INNER JOIN categories AS c USING (catID) WHERE b.ISBN = '{$ISBN}' END;
When I first saw this, it definitely made a 'whoa' impression.
Code: Select all
<?php
$sql="SELECT b.prodID, b.catID, b.title, b.market_price, b.sale_price, c.category, c.page
FROM books AS b
INNER JOIN categories AS c
USING (catID)
WHERE b.ISBN = '{$ISBN}'";
?>