Jump to content

boen_robot

Members
  • Content Count

    8,493
  • Joined

  • Last visited

Everything posted by boen_robot

  1. It's not up to you to set up HHVM. It's up to said shared host to do that, and most don't, since that's not "the" PHP interpreter, and their clients will likely complain because of that.
  2. 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)
  3. I think it's actually getting it from the OS.I haven't even heard about an "envvars" file to be honest... you could instead use "SetEnv" in the httpd.conf or .htaccess files though, if you want to use a PATH specific for Apache.
  4. 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.
  5. It's the job of screen readers to do that.There are a few CSS properties you can use to influence their behavior when they enter a certain portion of text (e.g. make them read it in a higher/lower pitch, slower/faster, etc.), but it's up to the user to first install and trigger the use of a screen reader.
  6. 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.
  7. 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">
  8. 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.
  9. "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]);}
  10. 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>
  11. boen_robot

    mysqli

    FWIW:W3C != W3Schools
  12. "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.)
  13. The MySQL connection also needs to explicitly use UTF-8. See mysqli::set_charset().
  14. @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)?
  15. 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.
  16. boen_robot

    PHP Config edit

    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.
  17. At www.eduardlid.web44.net, there are only two divs (#container and #main) :huh:Or are we talking about a different page again? Could you give a link to the exact page with the problem?
  18. Use a service like No-IP, and install their client to keep your name and IP in sync.Once you have that, your site will be accessible from your domain name.
  19. 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.
  20. 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.
  21. 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);
  22. 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.
  23. 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.
  24. Really? With statements like and 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...