Jump to content

boen_robot

Members
  • Posts

    8,493
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by boen_robot

  1. How many classes are we talking about anyway? PHP is very fast at parsing. Most penalties come upon the use of a component, be it a method or a class. It will take more than 1000 classes before the loading time alone becomes significant. In terms of usage, YMMV, but typically somewhere around 100 classes is where things become noticeably slower (although still bareable), and you need to implement some sort of a caching mechanism. (Note: These numbers assume classes with methods of typical lengths - between 10 and 100 lines; not "monster" classes, or a class with a "monster" method; also, no connects with external sources, such as a database, since that's most often THE bottleneck, and would be so even in a compiled code)

    • Like 1
  2. I want to learn JSP instead of PHP because I've heard jsp code is much cleaner than PHP
    Just FYI... this is pretty much not true.PHP, as a language, especially its later versions, allow you to write code that is as elegant, if not more elegant, than a Java equivalent.The "problem" with PHP that still exists is that it also allows you (and inherently => other developers that you may or may not end up working with) to write messier code than what Java would let you get away with.With good discipline and coding standards in place before a project starts, your PHP code can be protected from this.
  3. The tags in your source are in the "http://www.tei-c.org/ns/1.0" namespace, while the tags in the output are in no namespace.XSLT's copy-of makes sure the copy is also like that.There are a few ways to work around this, but the easiest would be to edit your XML so that the XHTML elements actually use the XHTML namespace and alter the top of the XSLT to use the 2nd method above.

  4. That shouldn't be happening... But there's three ways you could try and remedy it. 1. Force the output to be HTML, by using the xsl:output element, e.g.

    <?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"		xmlns:t="http://www.tei-c.org/ns/1.0"><xsl:output method="html" />

    2. Accept the fact that there will be a namespace in the output, and make it explicitly be the XHTML namespace, i.e.

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"		xmlns:t="http://www.tei-c.org/ns/1.0" xmlns="http://www.w3.org/1999/xhtml">

    3. Maybe (just maybe, I'm not sure), the cause is... well... it's hard to explain without lots of terminology, so let's just say "try this":

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"		xmlns:t="http://www.tei-c.org/ns/1.0" exclude-result-prefixes="t">

  5. One bigger query is always preferable. However, you should use appropriate LIMIT clauses whenever that makes sense, so that each subquery can be as fast as possible and deliver only what's needed.So for example, if you're only displaying the first 100 records, adding "LIMIT 100" at the very end is not just a nice to have, but a must.

  6. "database.accdb"?!?!?Are you trying to use MySQLi to access an MS Access (2007+) database? If so, that simply won't work.The fact you're not getting an object means the query failed, so $result is a boolean false. You can check the reason for the failure at the $error property, e.g.

    $maill = $_POST['fmail'];$passwordd = $_POST['fpass'];$mysqli = new mysqli("localhost",$maill,"");/* check connection */if ($mysqli->connect_errno) {    printf("Connect failed: %s\n", $mysqli->connect_error);    exit();}$mysqli->select_db("database.accdb");$result = $mysqli->query("SELECT * FROM user WHERE mail=$maill AND password=$passwordd");if (false === $result) {    printf('Error %s: %s', $mysqli->errno, $mysqli->error);} else {    $row = $result->fetch_row();    printf("Default database is %s.\n", $row[0]);}

  7. Your XML uses namespaces.To reference a namespace in XSLT (or really, in XPath), you need to register it first. You can do that by choosing an arbitrary prefix at the top of the XSLT. The only important part is that the URI is exactly the URI at your XML. e.g.

    <?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:t="http://www.tei-c.org/ns/1.0">   <xsl:template match="/">  <html>  <body>    <h2>            <xsl:value-of select="/t:TEI/t:text[1]/t:front[1]/t:div1[1]/t:head[1]"/>               </h2>  </body>  </html> </xsl:template> </xsl:stylesheet>

  8. "rotate" is a kind of "transform". Other kinds of "transform" are "translate" and "scale".(Think of it as comparing "apple" and a "fruit"; "apple" is just one kind of fruit, and other examples of "fruit" include "pear", "orange", "strawberry", etc.)

    • Like 1
  9. @Deirdre's DadYep, sounds like that's the goal.I'm not sure of a good solution, given that there are different resolutions out there, combined with the fact that if the bottom content overflows, he'd still probably want the content to appear below the fold (right Eduard)?

  10. Well... in all honesty, if you use classes, then indeed, you can pretty much do anything with them as opposed to doing it with references.References are one of those remains from pre-OOP times. In compiled languages (ala C and C++), they are also useful for reducing memory footprint (since you have one value being passed around, as opposed to it being copied around), but in languages like PHP, the runtime (in this case - the PHP interpreter) takes care about ensuring only a single value is passed around, and gets copied only if your code requires it (e.g. if you modify the value within the function).If you take objects out of the equasion, references are useful when you need a function to modify data that will be used later AND need its return value to signal something else. You can see examples with PHP's own functions, such as preg_match_all(). On the one hand, the return value is the number of matches, and on the other, $matches is a variable that's modified to contain each match.

  11. As hinted by kanchatchai, there isn't exactly a native way of reading and writing configuration.There are however various libraries that allow you to store configuration in various formats, such as PEAR::Config or Zend\Config.If you want to avoid using libraries, the easiest way is to store the configuration in an array. Use something like

    file_put_contents('config.php', '<?php return ' . var_export($config, true));

    to write the file, and simply use

    $config = include 'config.php';

    to read it.Manipulate it as you would any other array.

    • Like 1
  12. Other than having the appropriate extension enabled, there's nothing else in php.ini.Having the connection details (IP, username, and password for the connection), should be enough for the PHP code.If you're still having problems connecting, it could be due to firewall issues - the web server machine needs to allow outgoing connections on the DB port, and at the DB server needs to allow incoming connections on the DB port.

  13. You're missing the point of a reference - with a reference, the value can be changed so that code outside the function can see a value that was set inside the function.Try the following test code:

    <?phpfunction foo(&$var){    $var++;}$a=5;foo($a);echo $a;// $a is 6 here?>

    and change nothing but the "&" at the function.You'll see that with reference, the echo above (which is outside the function) is echoing 6 rather than 5, and without reference, you're echoing 5.

  14. The output from file() are strings of lines, not integers. The rules for comparing strings are different.You need to go over the lines, and convert the strings to numbers before you check them, e.g.

    <?php$salary = file('salary.txt');for($i=0, $c=count($salary); $i<$c; ++$i) {    $salary[$i] = (int) $salary[$i];}//OK, now it's all integersecho max($salary);echo min($salary);

  15. Here is the first time where the problem starts:

    < updateDate>1353600101304</updateDate>

    You can see the start tag starts with a space. That's not a valid XML. Whoever is in charge of generating the XML at api.tradedoubler.com needs to fix that, and you should contact them.It's possible that it previously worked on your PC server either because the point where problem with the other end was introduced, coincides with your migration OR (more likely) because your PC server's XML parser was different from your host one, and your PC one somehow recovered from that error.

  16. You may be thinking of this the wrong way.You can use the XPath count() function to get the total number of nodes in a node set, and you can do so separately from the whole processing. Within processing, you can use position() to get the posistion of a node within a node set, which is sure to increment on each iteration of that node set.The only case where this is not enough would be in a recursive template. In that case, you can add a parameter to the template that defaults to 1. Increment that counter upon making the recursive call.

    • Like 1
  17. As u reply I just want to told u that i am not feeling insulted by any mean, why should i ? Who r u ? & Why should i feel insulted by ur useless post ?
    Really? With statements like
    U don't have any rights to teach me.
    and
    I posted that rudely coz i am really hating members like davej coz they are creating scenes.
    you sure fooled me. Or am I (again?) not reading things properly?Anyhow... I'm going to close the topic for dicussion, but not delete it.People who want to learn together with JACK_22 - send him a PM or whatever.
×
×
  • Create New...