ignace
Moderators-
Posts
6,457 -
Joined
-
Last visited
-
Days Won
26
Everything posted by ignace
-
You clearly misunderstood the use of Value Object's. A Value Object does not contain an identity. Value Object's are to keep your domain model simple while still being able to fully encapsulate your model (and not breaking the client contract in the future). Eric Evan defines a Value Object as:
-
In most cases it are PHP (junior) developers who convert PSD documents to HTML/CSS not the designers. Ask a designer for the DOCTYPE and he'll answer you ".html". A (junior) developer knows PHP, SQL and possibly HTML, CSS, and JS as these are part of the basic skill set. Only few also know DTD and XSLT hence why I said there's a learning curve.
-
Only to those developers that don't think before they act. A framework is not a one-size fits all (in contrary to what you would believe of a framework), the framework designers had a few goals in mind and these may or may not conflict with your project, prototyping a framework prior to development is generally a good idea. This surely is an advantage however it's harder for other people to join your team (lack of documentation, possibly even tests)
-
subscribe-feed.php $sql = 'INSERT INTO point_system_actions (user_id, action_name, action_taken_on) VALUES (' ... if(mysql_query($sql)) { $sql = 'UPDATE point_system SET points += 10 WHERE user_id = ' .. login.php $sql = 'INSERT INTO point_system_actions (user_id, action_name, action_taken_on) VALUES (' ... // unique idx_action (user_id, action_name, action_taken_on) if(mysql_query($sql)) { $sql = 'UPDATE point_system SET points += 10 WHERE user_id = ' ..
-
IMO there is only one bible: Expert PHP and MySQL
-
i need more of an understaning of the following...
ignace replied to son.of.the.morning's topic in PHP Coding Help
So these 9 lines are harder to comprehend then your 30-40 lines of code? if(upload_exists($_FILES['file'], 'directory')) { echo 'Upload already exists.'; } else if(!upload_is_valid($_FILES['file'])) { echo 'Invalid upload.'; } else if(!upload_store($_FILES['file'])) { echo 'Could not store the file.'; } else { echo 'File successfully created.'; } -
i need more of an understaning of the following...
ignace replied to son.of.the.morning's topic in PHP Coding Help
If you have trouble understanding your code or someone else's consider re-factoring the code: if(upload_exists($_FILES['file'], 'directory')) { echo 'Upload already exists.'; } else if(!upload_is_valid($_FILES['file'])) { echo 'Invalid upload.'; } else if(!upload_store($_FILES['file'])) { echo 'Could not store the file.'; } else { echo 'File successfully created.'; } function upload_is_valid($upload, $valid_mime, $valid_ext) { if($upload['error'] != UPLOAD_ERR_OK) return false; $finfo = finfo_open(FILEINFO_MIME_TYPE); // Note: PHP 5.3.x if(!in_array(finfo_file($finfo, $upload['tmp_name']), (array) $valid_mime)) return false; if(!in_array(pathinfo($upload['tmp_name'], PATHINFO_EXTENSION), (array) $valid_ext)) return false; return true; } function upload_exists($upload, $directory) { $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME); return file_exists(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename); } function upload_store($upload, $directory) { $upload = upload_create($upload); $filename = pathinfo($upload['tmp_name'], PATHINFO_FILENAME); return move_uploaded_file(rtrim($directory, '\/') . DIRECTORY_SEPARATOR . $filename); } function upload_create($upload) { // re-create the image return $upload; } -
Sure, but what prohibits them to just strip it? To a basic user... that buys a script from you somehow knowing his server runs PHP and performs all required installation instructions?
-
In contrast with Smarty it presents a learning curve as the markup is somewhat complex to understand and follow. You also will have to deal with learning yet another "language".
-
LOL nice RIP I actually like the RIP better
-
I'm currently at the part where you write PHP extensions but I do not publish them as these are custom to the company I work for. A good book for everything PHP/MySQL is Expert PHP and MySQL
-
I think their may be a problem: Internal Server Error
-
/ignore /face-palm
-
1. Create 8 files with distinct names - register.php - login.php - dashboard.php - ... 2. Write the required code in each page and include() the common sections: $headTitle = ''; $headDescription = ''; include 'html/head.php'; include 'html/menu.php'; // code include 'html/foot.php';
-
You can only learn PHP by practicing it. Buy a PHP cookbook this will give you some stuff to practice. Buy a book about PHP best practices to correct whatever the cookbook wrongfully told you or display your examples on these forums (people will tell you what you should and shouldn't be using). Push your boundaries by trying out new and more difficult problems. Retrieve 2 year old code and re-factor it without actually re-writing it and make sure it still works after your done. Keep doing this for all your code. This will also be an indicator of your progress. This will make you a competent PHP programmer not an expert PHP programmer. To take the final step you should start with expert training like Zend Certified Engineer, this will make sure you know of everything that PHP gives you. Next, start writing extensions and hacking the PHP core. You are an expert PHP programmer when your extension gets published and comes pre-bundled with PHP, by that time you'll have many years under your belt and are probably already consulting for companies that deploy PHP applications. Good luck
-
Do not make it too difficult, too complex and unmaintainable: updateAge('forum_posts', 'foo'); // doesn't make sense but is currently possible in your design $db = mysql_connect('localhost', 'root'); if($db === false) { trigger_error('Failed to connect to the database server.'); } if(!mysql_select_db('test', $db)) { trigger_error('Database test does not exist or could not be accessed.'); } function person_create($data, $db) { if(!person_is_valid($data)) { trigger_error('Invalid user data. User has not been created.'); } $sql = 'INSERT INTO users (user_name, user_pass) ' . 'VALUES (' . db_input($data['user_name'], $db) . ',' . db_input($data['user_pass'], $db) . ')'; mysql_query($sql); return mysql_insert_id(); } function person_is_valid($data) { $data = array_merge( array('user_name' => '', 'user_pass' => ''), $data ); return !empty($data['user_name']) && !empty($data['user_pass']); } function db_input($input, $db) { return "'" . mysql_real_escape_string($input, $db) . "'"; }
-
LOL I overwrote my own post
-
Or if you have it laying around, an hydrogen bomb.
-
Only XHTML had the space + forward slash while the space was actually only for backwards compatibility with older browsers that would not understand XHTML. The forward slash is used in XML to note that it doesn't have a closing tag. XHTML is pretty much obsolete, XHTML2 has been discontinued in favor of HTML5 and XHTML1.x has never been supported by IE. Either use HTML4.x or 5 using for example the boiler plate code from Paul Irish
-
I found a few issues layout-wise when viewing the website with Firefox 3.6.8: - Shop by category: The arrows are on the next line instead of in front of the text, the border-top has a nasty jumping effect. - Language: the language icon is below the language selection box - Mailing list: the text box does not expand to it's full width Other issues I found: - I can't add a product to basket directly - Do NOT prohibit basic functionality to keep working, I can't add something to the basket because I have JS disabled. Another reason for providing backwards compatibility is when by accident you upload something or wrong logic executes and that breaks your JS.
-
As you clearly have had sufficient practice it becomes obvious you need to seek other ways to advance, consider training or books. "Practice without theory is blind, theory without practice is mere intellectual play" -- Unknown
-
When they open it and... read it. You can stop at when they open it.
-
Base your website on one currency and store the conversion rate in a currencies table.
-
No, you don't. Open/Closed Principle Due to the Shopping_Cart design (or lack thereof) this becomes more difficult to implement as an item alone should know how much it costs. You can solve this by using the Proxy Pattern: class Shopping_CartProxy extends Shopping_Cart { function getItemPrice($order_code) { $db->query(..); return ..; } } Use the proxy as if it is the Shopping_Cart (if you use a Factory Method to create the Shopping_Cart you'll only have to modify the Factory Method) public function someFunction(Shopping_Cart $sc) { .. } $proxy = new Shopping_CartProxy(); .. $o->someFunction($proxy); class ShoppingCartRepository { function purchase(Shopping_Cart $sc) { $db->query(..); } }