Jump to content

boen_robot

Members
  • Posts

    8,493
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by boen_robot

  1. The effects of min/max-width/height become most apparent when width/height use relative units, while min/max-width/height use absolute ones. With those combined, you'll be saying, for example "Have this element 100% (width) of the window width, but if this width is less then 100px (min-width), stretch it to be exactly 100px, and if it's larger than 800px (max-width), shrink it to 800px".
  2. For properties, it specifies at what point can the value be read or changed, and for methods, at what point can they be executed.Private - only within the class that declared it.Protected - only within the class that declared it, and its children (i.e. classes that extend it, as per this part of the manual).Public - at the class that declared it, its children, and at every instance of the object (or in short: at any point).If that's not enough, you'll have to be a little more specific about what you don't understand (with examples and specific questions like "what would happen in the following scenario: [insert code]").
  3. Where it says ".txt", it should be a dropdown menu. If you click the arrow next to it, the other option should be "All files". Press that, and then whatever name you give your file, that will be it - no ".txt" added to it.As far as encoding goes, change that to UTF-8 instead, and in your HTML's head, add <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> (it's hard to explain right now... you'll get it when you reach PHP)BTW, any "HTML editor" will do the trick too, not just Notepad++.
  4. boen_robot

    Unloading a class

    Not exactly... the two classes need to be defined in two different namespaces, at which point you can refer to either by a third namespace declaration at the top of the file where you use the class. Depending on that declaration (which is allocated per file, so if you need it conditionally, you'll have to conditionally include different "use" files), you can instantiate either or both classes from a single file.If you can open up the two versions, and add namespace SomeNamespace1; to the top of the first, and namespace SomeNamespace2; to the top of the second, then, in your code, you can have use SomeNamespace1\ClassName as ClassName1;use SomeNamespace2\ClassName as ClassName2;//Further on...if (/*situation check*/) {$class = new ClassName1();} else {$class = new ClassName2();}//Use $class unconditionally
  5. It is possible by any chance that you could split your XML file into several ones (and process them separately) OR use a SAX parser to only process fragments at a time?XSLT 1.0, as well as XSLT 2.0, does not have any "stream" capabilities - all of your content is parsed and held into memory. Because the presentation of a node takes more memory that the textural representation, combined with the fact that some DOM implementations place internal IDs to make DOM more efficient, transformation ends up taking a lot of memory... so much so, that all possible internal ID values are exhausted. I don't know if Apache's DTM has a setting of turning off internal IDs, but if it does, that means that your transformation will take significantly more time to process.XSLT 3.0 is planned to have streaming capabilities, but that's for the far future (well, a few years, up to a decade really; you know how fast technology is moving). For now, SAX and file splitting are the solutions.
  6. boen_robot

    Unloading a class

    Why do you want to do that anyway? If the problem is in loading order, you can prepend a different autoload function that would load the correct class.
  7. As for the "Error suppression ignored for" notice. This means that you have (or your host has) configured PHP to ignore the error suppression operator (you know, the "@"), and show errors anyway. This notice essentially means that a "@" was found, and because of that setting, it is being ignored, so you're being notified that, if you happen to see an error originating from that line, you're only able to see it due to that setting.BTW, using the "@" operator in general is a bad idea. It's best to test for the possible error conditions beforehand instead. There are very few cases where that's not possible, and in those, the use of @ should be immediately followed by result inspection (e.g. if a problematic function would return false on failure, check if the result was false), and error handling.
  8. You're showing different scripts it seems. Maybe you forgot to sync them yourself.If I type "q" as the query, I get request to the URL /in-search.php?name=q&nocache=0.9572214348696474 Notice that the query is in "name". And your PHP script instead uses $_GET['searchq'] which means that the SQL statement ends up ALWAYS returning the first two entries.Change http.open('get', 'in-search.php?name='+searchq+'&nocache = '+nocache); (which is different from what you're showing above BTW... I took this here from the link you gave me)to http.open('get', 'in-search.php?searchq='+searchq+'&nocache = '+nocache); To avoid similar problems, I highly suggest you open up your browser's development tool (as specified in point 3.2. at this topic), and monitor the URLs (and the shown headers and body) that pops up as you search.
  9. A link to the problematic page please?
  10. Just to let everyone know, I used the "Report error" link at the bottom of the page, linking to this page for the fix.If you encounter an error that you know how to fix, you can use that to notify the W3Schools staff about it. If you don't know how to fix it, we can do what we just did for this error.
  11. I've swapped the topics back now. I see no reason not to, since that credit IS given, even though the forum is not about that.
  12. For f###'s sake! The intention was never plagirization!!!!! :glare:I'm sorry if it looks that way, and if you stop acting like I've stolen a toy or something, you'll realize I'm trying to make up for this accident (because that's what this IS). I didn't settle out with the intention of "stealing" your content, but with the intention of improving it (by means of adding those things you hate so much - headings), for the benefit of people who wouldn't read through all of your damn content as it is currently. The alternative was modifying your original post - an alternative that you lashed out from the start, yet apperead to agree with a brand new post that's based on your content, with credits in it. OK, maybe "Some content based" was a poor choice of words for crediting you. I apologize for that, and would like to fix it, if you let me.This topic is now pinned, the other is unpinned... as before. Happy now?
  13. I've changed that to Happy?If not, how would you like me to phrase it?The only reason I initially phrased it as "Some content based" is because a few points are entirely new (HTTP debuggers...), entirely rewritten (View Source...), while some are heavily cut out or simply altered beyond their original intent (var_dump() instead of plain echoes...), or simply contain minor edits not previously stated explicitly (almost all other points), so "some content" seemed like a fair statement, combined with the fact I actually link back to this content.The way this phrase goes is entirely unimportant to me (it's not like I didn't even mentioned this content...), but if it's so important for you, I'll phrase it any way you like. There's no need to act like a prima-donna about it.
  14. Yes. Specify the third argument to the correct charset. If your PHP document is encoded in UTF-8, as it should be, specify "UTF-8" there.
  15. Nope. the fault is in the array_search() alright... I made it analyze the first dimension of the $res array, rather then the array within the "conteggi" key. So replace that with $c = $res['fissi'][array_search($f, $res['conteggi'], true)];
  16. << Topic unpinned >>I've left a link to it though from a new "tidy" version.
  17. (Based on earlier writings by "So Called" in this topic)1. Organization tips for all of programming 1.1. Start smallMake your big problems into little problems! Don't write 200 lines of code and then ask us why it doesn't work! Instead, write 10 or 20 lines of code and get that to work. Other things being equal, 20 lines of code will have 1/10 as many bugs as 200 lines of code. You are 10 times as likely to write good code if you write just a little not a lot, and 10 times more likely to have willing volunteers on the forum help you find out why it doesn't work. On a related note, don't write a whole mess of HTML, PHP and MySQL queries (even if it's well under 200 lines of code) and then ask yourself (or the forum) why it doesn't work. Write a few lines, test it, fix what's broke, then add more code. Don't add more complexity until you get what you've already written to work. This is the stage where you can expect help from an Internet forum. 1.2. Keep it readableSpeaking of creating a mess, avoid creating one by keeping your code readable. A lot of problems can be avoided or fixed quickly if you and other people can find their way around your code. You might have overlooked this as a "minor feature", but it's actually really important for this point - you can freely insert white space between different parts of your PHP code. This means you can (and should) insert white space wherever it makes logical sense. If you're not sure, err on the side of being with white space. For example, instead of <?php$f=$_GET['f'];$l=$_GET['l'];$r=0;for($i=0;$i<100;$i++) if($i%2===0||$i%5===0)$r+=$i;echo "$f $l: $r"; make that <?php$f = $_GET['f'];$l = $_GET['l']; $r = 0; for ($i = 0; $i < 100; $i++) if ($i % 2 === 0 || $i % 5 === 0) $r += $i; echo "$f $l: $r"; Also, use meaningful variable names that tell you what a variable is used for. For example, instead of the above, have it as <?php$firstName = $_GET['firstName'];$lastName = $_GET['lastName']; $result = 0; for ($i = 0; $i < 100; $i++) if ($i % 2 === 0 || $i % 5 === 0) $result += $i; echo "$firstName $lastName: $result"; And finally, if brackets/braces/whatever are allowed, but optional, use them anyway, to clearly define the intended boundaries, e.g.: <?php$firstName = $_GET['firstName'];$lastName = $_GET['lastName']; $result = 0; for ($i = 0; $i < 100; $i++) { if (($i % 2 === 0) || ($i % 5 === 0)) { $result += $i; }} echo "{$firstName} {$lastName}: {$result}"; If you search the web, you'll find different advises on how much and where should white spaces and brackets/braces be (e.g. some programmers prefer the opening bracket on a new line, while others prefer it on the same line as the statement - as above). No style is truly "better" than another. Whatever feels readable to you, use that. However, it's important to note: Whatever your preference is, be consistent. Don't use one style at one place, and another style at another place, as this makes your code harder to read.(Also worth noting: Some PHP editors allow you, with the click of a button, to automatically add white spaces according to predefined rules, so that at least the first part of what we did above is automated) 1.3. Probe your codeAsking for help on the forum may get you help in hours, days or sometimes weeks. But ask your code the same questions and you may get answers in seconds or (at worst) minutes! The remainder of this topic will address how you can ask your code to tell you why it won't work. These things are not "fixes", they're means to finding a fix (which is essentially what "debugging" means).
  18. Blowfish or SHA-512, using crypt(), and with a high cost/rounds parameter. Because those two, when given high values, take most time to compute. From what I've read, it seems like blowfish wins in the "most time to compute a single attempt" department, while SHA-512 produces a larger hash, meaning that it takes more attempts to come up with an input string that would produce an equivalent hash... In theory that is. In practice, currently, it's impossible to come up with an equivalent string for either Blowfish or SHA-512 without brute force, at which point the "time to compute a single attempt" is more important.
  19. Let's do this with the concrete values first. You can abstract it later with "real" values. Your full $res array can be expressed like so: $res = array( 'conteggi' = array(40, 80, 120, 160, 200, 240, 280, 320, 360, 400), 'fissi' = array(80, 320, 720, 1280, 2000, 2880, 3920, 5120, 6480, 8000)); With that in your code, the most efficient way to get what you want: $f = max($res['conteggi']);$c = $res['fissi'][array_search($f, $res, true)]; Now... to generate the array properly, let's see your generation code: $i=0;$countLow=0;$fissoLow=0;for ($i=0;$i<10; $i++){ $z+=2; $fissoLow = 10*2*$z; $countLow = $fissoLow*$z; $res[]=array("fissi" => array($fissoLow),"conteggi" => array($countLow)); } This appends new arrays onto $res. It doesn't append on $res' subarrays ('fissi' and 'conteggi') - new 'fissi' and 'conteggi' arrays are created, and added on the $res array. To put this in another way, your code generates the equivalent of: $res = array( array( 'fissi' => array(80), 'conteggi' => array(40) ), array( 'fissi' => array(320), 'conteggi' => array(80) ), array( 'fissi' => array(720), 'conteggi' => array(120) ), array( 'fissi' => array(1280), 'conteggi' => array(160) ), array( 'fissi' => array(2000), 'conteggi' => array(200) ), array( 'fissi' => array(2880), 'conteggi' => array(240) ), array( 'fissi' => array(3920), 'conteggi' => array(280) ), array( 'fissi' => array(5120), 'conteggi' => array(320) ), array( 'fissi' => array(6480), 'conteggi' => array(360) ), array( 'fissi' => array(8000), 'conteggi' => array(40) )); and that's very different from what we set out for. Instead of creating new arrays, you need to append to the existing ones, just as we did with $res - using the "[]" operator. BTW, you should also initialize your $z variable... so: $z=0;$countLow=0;$fissoLow=0;$res = array();for ($i=0;$i<10; $i++){ $z+=2; $fissoLow = 10*2*$z; $countLow = $fissoLow*$z; $res['fissi'][] = $fissoLow; $res['conteggi'][] = $countLow;}
  20. If it works, it's "suitable". Is it "efficient" is a separate concern. It isn't really.There are two ways to make it more efficient - collect all values you wish to find the maximum of ("candidate values") in a single array, and apply max() only once on that array OR assume the first candidate value to be the maximum one, then loop over the other candidate values, and whichever is greater, take it up as the new maximum. By the end of the loop, you'll have the greatest value.I'm not exactly sure what's the set of candidate values you're working with, so I can't code the above for you. But that's essentially the algorithm.
  21. Yes. You can open them as text files, although it's a better idea to open them using DOM or SimpleXML instead.
  22. At the line $res=array("fissi" => array($fissoLow),"conteggi" => array($countLow)); you're replacing the whole $res array, so $res will always have just one entry. Replace that with $res[]=array("fissi" => array($fissoLow),"conteggi" => array($countLow)); to append the new array onto $res. BTW, you'd also have to define $res first, like $i=0;$countLow=0;$fissoLow=0;$res = array();for ($i=0;$i<10; $i++){
  23. Then you don't really need a certificate. Most clients aren't interested in that, but are instead interested in seeing a portfolio. Do some work for free (at least once; ideally for a friend or relative), and then show off the site when you advertise yourself to potential clients.The certificate is only interesting to employers, who need assurance that you don't just make stuff that looks good, but that you actually know what you're doing.
  24. You can see a few examples on the manual page: Redirect to another page (either instantly, or after a delay), force the page to be downloaded as a file as opposed to being displayed, change the Content-Type (if you're outputting something other than HTML, like an image for example), set caching headers, allowing your PHP to be invoked in full less often (though you need to also inspect request headers, and act accordingly, so this can be tricky, and sometimes not worth it), do HTTP authentication (you know, the kind that shows a dialog box in your browser), etc.
  25. It's important. Yes.In some contexts, in some browsers, things are "case insensetive" (i.e. you can write with capital letters, or lower case letters). But to be sure, you should write everything in a case sensitive fashion (i.e. write it with whatever letters the spec/library/whatever asks you to).
×
×
  • Create New...