Jump to content
Larry Ullman's Book Forums

Antonio Conte

Members
  • Posts

    1084
  • Joined

  • Last visited

  • Days Won

    126

Everything posted by Antonio Conte

  1. $user = array(); $quote = array(); $_SESSION[$user]; $_SESSION[$quote]; Print_r($_SESSION); You are pretty much there. Just assign the arrays to keys in the session array. (as illustrated above)
  2. I will try using unset(). That's not such a bad idea. The problem with namespaces, is that I do not know how to use them yet. Will try it. The customer does not require the native sessions to work, but as I see there's demand for such a plugin, I want to implement it. Counting the number of threads on the WP board, there's definitly a marked.
  3. From the mysql manual on Substring: For some reason, mysql don't start the count from zero, which is in many ways "the standard". I would guess something like this might work: substring(postcode, 1, 5) SUBSTR() is only a synonym for substring, so if the above works, both will work.
  4. Hey, everyone. Working on a pluginen for Wordpress right now. It will allow you to comment articles as a phpBB3 user. The problem has to do with phpBB3s native session solution. By including the file "common.php" and doing some authentification against phpBB3, you'll have support for phpBB3 sessions outside of the forum solution. The problem is that both phpBB3 and Wordpress are polluting the global namespace. Global variables such as $db, $theme, etc, is used by both system. We also have function naming conflicts. Functions are pretty manageable. Because I can run those few functions I need inside my own classes, this works fine. The problem is those global variables that crash WP when included from phpBB3. Is there a way to unset the global variables or a way to use PHPs new namespaces to solve this issue? I guess both PHP and JavaScript developers might be able to answer me that.
  5. It was more of a joke, but it really should not be that hard. After building a simple Code validator, I can assure you it's fully possible. All you have to do is look at one char at the time, line by line, and interpret the code.
  6. It's very common to see this pattern in Java. There you implement the simple interface Comparable which requires a compareTo method. That is basically doing the exact thing as you see here. The problem with PHP sometimes is that you miss these kinds of things. They are not hard to do, but you don't see them that often in PHP. The Comparator interface in Java is also very interesting. From that basic interface, you could make your own sorting algorithms for any object collection. Static functions like Array.sort() and Collections.sort() will allow you to use different Comparator objects to sort different ways. This comes pretty much out of the box with PHP, but you make some sacrifices for this simplicity. If you look at the function naming "cmp", my guess would be that it stands for Comparator. That would maybe give you a better understanding.
  7. Why? It shouldn't be a problem coding one. Maybe we got a business idea here.
  8. Very good point. That is also why Facebook is developed in PHP before parsed to C++. https://github.com/facebook/hiphop-php/wiki/
  9. Facebook is not really what's important here. I just used them to illustrate my facination. Might as well have used Youtube as the example. What's kind of unique is the growth rate. Both youtube and facebook grow very fast in traffic from the start. It's just amazing how they've handled that, espacially Facebook. Their downtime numbers are incredible regarding the growth!
  10. Don't quite agree. That kind of traffic's sky high. I have very little interest in Facebook from a user perspective, but they interest me very much as a developer. Facebook tries to stay open source and has been enchanting several libraries. They have also made a lot of contribution other large IT-companies has benefited from. It's a pretty amazing company once you get over the fact you don't care from a user perspective. Sorry if this starts to get a little bit off-topic btw. We kind of ended up talking performance here.
  11. Very interested in this topic generally, especially websites that scale like hell. We've had a lot of talk about Ddos attacks here in Norway the last couple of weeks. Some script kiddies has brought down the national bank's website, several online news papers and IT-sites. Then take Facebook. When they released unique usernames, they did so for everybody at once. 200 million users fought over the same unique user names. In effect, they almost asked about getting Ddos'd from their own user, still, the website stayed up! Amazing! Same for images. Over the years, Facebook has gradually decreased the number of access to disk from 16 to 1. There's several other stories about how they have optimized the site over the years, but Facebook is literally coded in PHP, compiled in C#, and use memcached and MySQL. That's just amazing scaling! Facebook has unique content queried for every single user, still they manage astonishing amounts of traffic every single day. The dream job? Working at Facebook! They seem like such an amazing company.
  12. Just wanted to recommend a website called CodeCademy.com. They offer free courses in Javascript, html, css, Ruby and several other languages and courses. It works kind of like a lot of those new apps you find on your phone. You get a task, you provide an answer, that answer is validated, and you can move along to a new course once finished. People learn differently, but I diffidently need to write code alongside learning. For those new to JS, I would definitly recommend reading Larry's book along with these tasks. You'll find out you learn a lot fast and in a fun way. Some of the tasks involve several revision of a black jack game, a cash register and other fun tasks. You also get trophies from a point system considering how well you've done. A very enjoyable and good way to deploy JavaScript code. Has anyone else tried it?
  13. You care to provide some resources? I've previously used some for CSS, but never for PHP, JS or html.
  14. I'll pick those I can answer. The point here is that you should be able to create classes in PHP that are very portable and deployable in new site. When you find yourself copying a lot of classes from your previous projects, you know you are doing something right. (probably) Object oriented code is all about the re-usability. That takes us to the next pseudo-question of yours. Developing solid classes takes time. It's all about the details. You'll polish those classes until they are easy customizable and easy to work with. When you are writing examples to make a point, object-oriented programming isn't always the right choice. There's absolutely nothing wrong about writing procedural code. Sometimes you need a full functional class, sometimes you need a static helper class (sorting, etc) and sometimes the best thing is going procedural. OOP is not the king every time. Without knowing what the discussion is really about, I dare make these general comments, so go easy on me if I missed something.
  15. That just sound slow! I remember one of those games from I was little. You played as two monkeys throwing bananas at each other. Kind of like multiplayer angry birds. Crappy resolution and it did only run in dos, but I really liked it. My granddad had to do some "magic" every time before we could play it. Oh, the good old games. I still play my Nintendo Nes from time to to. Great memories!
  16. All the large site's do it. To much unnecessary whitespace. For us normal programmers, though, I think we should care about nice code and whitespace. That's why I do my echo's like that. It'll give you nice source code even without line break. (Or I'm applying them myself at least.)
  17. I've always just done echo statements like this: It works great, but I'm kind of embarrassed now. I've always done like Edward and thought those line breaks did nothing in PHP. Edit: Posting an image instad...
  18. You can write games in Java, but I don't think it's the language of choice. Haven't really played that much with images yet, but standard drawing works good. Not really my field there. My girlfriend has a class in game programming this year. They code in a C# framework called Microsoft Xna. The games coded are easily run on computers, Xbox360 and maybe some other gadgets. (So you are onto something here, Larry and Edward)
  19. I did some research, and neither does CodeIgniter. You need to download drivers for both frameworks. (Both has one available) Just assuming, but I think that is why he wondered about using their own DB classes. That should be very much possible in Yii. I haven't seen CI stating the same, but I'm sure it shouldn't be a problem.
  20. Without having extensive knowledge of Yii myself, I've seen that Yii has both Active Records and an object-oriented QueryBuilder class. You should have a lot of flexibility there. From a general point of view, why should using you own Database classes be a problem? Looked it up for you: Here is also information about including 3-party libraries: http://www.yiiframework.com/doc/guide/1.1/en/extension.integration Generally I would say this looks like a good alternative without knowing your specifics. You are the only one knowing what you need.
  21. Would guess ranks is a better word for it than groups. I don't know about IPB, but I would guess you can assign ranks based on post count. As you can see, you are now an "Advanced member" instead of the default "member". To be honest, I care very little for such things. I've been active on maybe 30-50 different forums over the last 10 years. Those forums that emphasizes post count often has a higher number of posts, but it affects the general quality. Especially for a forum like this - a programming forum - you'd want quality posts instead of lots of posts. I generally like this forum a lot. No "pissing contests", grown up members and a good tone. I'm also a fan av Larry's writing as he explains programming a way even a knuckle head like me can understand. I struggled a lot in the beginning, and I like to pass some of my experience back to those new to programming. I stick around because of this. Edit: I've also hung out at English speaking forums since I was maybe around 15. I feel I've gain a lot by having to think and write in English. So far, it has definitely made my a better writer, and also helped me gain confidence in my ability to speak English. I don't care about being 100% correct grammar wise or word for word, but I really enjoy the feeling of being able to write English without having to look up words and phrases all the time. Great exercise.
  22. Pretty much spot on. There are nuances here, but understand it one step at the time. Learn about the difference of "assigning by reference and assigning by value". That sounds kind of difficult to understand, but it's really not. It's important for properly understanding arrays and objects. Will let some others contribute to the rest.
  23. Look at the assignment in the while loop at line 62. Here he assigns all task ids along with their parent id to the $tasks array. ( $tasks[$parent_id][$task_id] ). On page 20, look at script line 74. Here the first element of the array is sent to the make_list function. ($tasks[0]) THIS is the $parent input the first time around. Also note the global $tasks. Because this function is recursive, (in other words, calling itself) it will loop through all task ids found in parent_id 0 before doing the same thing up to parent id N (number of elements.) Parent id 0, task 1, 2, 3.....n, then parent id 1, task 0, 1, 2, 3...n, then parent id 2 and so on. You can basically look at it as a nested foreach loop. Recursion is hard to grasp, but not very difficult. The code below will do pretty much the same thing. echo '<ol>'; foreach ( $tasks as $parent_id => $task_id ) { echo '<li>'.$parent_id; foreach ( $task_id as $task ) { echo '<li>'.$task.'</li>'; } echo '</li>'; // End parent id } echo '</ol>';
×
×
  • Create New...