Jump to content

LittleJoe

Members
  • Content Count

    35
  • Joined

  • Last visited

Everything posted by LittleJoe

  1. Thanks guys, you're the best.
  2. I need to loop through an array, in the order that the items appear, and get both the key of the item and its value. I know I can use foreach to loop through an array but as far as I know I can choose between the key and the value of the current item but not get both. Here's an example of an array: <?php$SampleArray = array(55 => "car","2" => "house","boat" => "boat",0 => "engine",666 => "website",);?> It would work somehow like this: loop($SampleArray){ echo key . " - " value . "n";} And the result would be something like:55 - car 2 - house boat - boat 0 -
  3. I'm wondering whether the lang attribute applies to the rendered content only or whether it also applies to metadata, comments and code (variable names, CSS id/class names). If my metadata etc is in US English but the rendered content is in French, which is the right way to go? 1) Language declared in the root element and then changed in the body element where the user content is. <!DOCTYPE html><html lang="en-US"> <head> <meta charset="UTF-8"/> <title>Title</title> </head> <body lang="fr"> </body></html> 2) Language for metada
  4. I'm talking about storing the JavaScript code inside PHP files (.php) and including it in your HTML/PHP files (include "javascript/menu.php") so that the contents of it appear to belong to the HTML page itself.
  5. I'm thinking about developing a website that will use the following dynamic architecture: index.php?id=1index.php?id=2index.php?id=3index.php?id=4etc. As opposed to the static (old school): index.phppage1.phppage2.phppage3.phppage4.phpetc. What are the pros and cons in terms of caching, search engine indexing and other stuff you can think of?
  6. People always say that if you have JavaScript code which is used by multiple pages then it should be in an external page but if it is only used by a single page in should be internal. People also say that external JavaScript code can make the browsing slower since additional PHP requests are made but that when it is internal less bandwidth is used. Is it a good idea to put JavaScript code into PHP files and then include them like any other PHP files? I've been thinking about this because then I can minimise the HTTP requests and at the same time use the same JavaScript files in many PHP files.
  7. I guess that makes more sense. Thank you guys!
  8. So we are then all in agreement that using a database for this is a no no?
  9. Not every translation in every language is loaded but every translation in the relevant language. Isn't that a bit much?
  10. I'm working on a website that I want to be accessible to speakers of many languages but I'm wondering how to architect such a website. I seem to have two options and I hope you guys can help me choose: 1) Database I could make a table that lists all the messages and then have individual language tables with translations of those messages. Each page would then make a dozen or more queries to get all the messages/content to populate each page. I'm a bit worried about what the effect this may have on my databases and whether it is too much for them to handle in addition to all the other queries s
  11. I have never installed such chaching technology and don't know much about it. Since I will be making use of shared hosting I will have to see what they offer.
  12. Yes, that did come to mind but I was just hoping there was an easier build-in option.
  13. Well if I'm forced to query the DB on every page then I suppose that's what I must do but I just wanted to see if I could just a session somehow to do it instead and alter the session automatically for that user because I always hear that you should do as few queries to the DB as possible and use sessions instead and doing a query on every page does sound DB consuming.
  14. When a user logs on my site a session variable is created to keep the user id and also whether said user is actually logged in (for those pages that require the user to be logged in to view them). Now, let's say I notice a user misbehaving and I want to kick him/her off or deactivate the user's account, if I stored the login state in the database I would just change the value of in the user's record but since it's in a session variable, how would I go about getting that particular user's session to modify it? I don't want to have to do a database query during every page load to see if an admin
  15. Delete this post.
  16. I wouldn't call the e-mail address verification proper user authentication. It's a lot harder for bots for example to pass the SMS/call-back thing.
  17. I've been developing a web application for many months and once it goes online I want the users of it to authenticate themselves after signing up. Of course I'll also ask users to verify their e-mail addresses like all websites do but I would like to properly authenticate the users but I don't know exactly how best to do it since the users will have different backgrounds and such. Originally I thought about credit card authentication – transferring 1 pound/euro/dollar to my merchant account and then use that as a credit for something on the site or to use PayPal in a similar fashion. I'm not t
  18. You mean the file name in the code or the contents of it?
  19. If I have statement such as: if ($something){include "large.php";}else{include "tiny.php";} Does the PHP engine parse through both files even though it doesn't use one of them when it begins to execute (interpret) the statement?
  20. I hope Zend will one day soon come up with a compiler for PHP - I don't like interpreters! All the solutions I've seen so far, such as HipHop for PHP, are too complex to set up on cheap shared hosting.
  21. Well my class libraries are still tiny then. Windows says 25.3 KB and 40.0 KB (size on disk). Then when I add third-party libraries to my site such as PHPMailer and perhaps GeoPlugin the size will grow considerably but I won't need them for every request.
  22. Well the only problem is that I don't really know what is a lot of time in PHP terms. Other things need to be taken into consideration as well. I imagine that the server (Apache, MySQL) will behave differently when it recieves one request on my localhost compared to thousands of requests per second when in production.
  23. Well those 6 require_once files have a class each except for "common.php" which has random functions that don't need to become methods in their own class. But as I said before, each class is loaded with methods that are not used often but there are always some methods used in each class (that is per HTTP request).
  24. Well in my case all the classes are used but they contain a lot of methods that are not used but rarely. I'm worried that PHP might use a lot of CPU to parse them all before interpreting the ones it needs to use in each instance.
  25. I'm designing a feature-rich website with object-oriented PHP and I have a performance question. My background is in C, C++ and C# (.NET) programming. Now all those are compiled whereas PHP is interpreted. The following require_once statements are at the top of each page: <?phprequire_once "_php/library/Session.php"; // Session class (session related functionality)require_once "_php/library/Databases.php"; // Databases class (database related functionality)require_once "_php/library/DatesTimes.php"; // DatesTimes class (date and time related functionality)require_once "_php/library/User.p
×
×
  • Create New...