Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. awesome. So it would be good for 0 == null <-true 0 === null <-false ? Yeah it all started because I didn't like 1 == true|1|'1'
  2. It isn't. I got in to an habit of using them to notify readers that I'm comparing two variables of the same type. I use == whenever I compare to an unknown source that may be or may not be a numeric string (in the latter it will return 0). Syntactical sugar == equal === identical
  3. Of course you need to connect all I am saying is that you should not create a class to merely wrap another, add functionality don't copy.
  4. class NewsManager { public function __get($offset) { $this->tableName = $offset; return $this; } public function getAll() {} } $nm->tableName->getAll();//SELECT * FROM $tableName
  5. @Natasha note that your server may not be supporting cURL
  6. I tried $dom->strictErrorChecking = false and $dom->validateOnParse = false but it kept giving warning's. Weird, I get:
  7. Your production server should be configured like this already. Just make sure that your input is what you expect like: preg_match_all('#href\="([^"]+q=([^&]+)[^"]+oi=revisions_inline[^"]+)"#miu', $googleRes, $matches); return !empty($matches) && 3 <= sizeof($matches) ? array_map('urldecode', $matches[2]) : array();
  8. You can also use XPath: <?php ini_set('display_errors', 0); $url = 'http://www.google.com/search?q=paintball'; $dom = new DomDocument(); if ($dom->loadHtmlFile($url)) { $xpath = new DomXPath($dom); $entries = $xpath->query('//div[@class="brs_col"]/p/a'); foreach ($entries as $entry) { echo $entry->nodeValue, "<br>\n"; } } But like Daniel already said:
  9. You don't need 2 different session's. You even can't have 2 session's. Just add the info for another section of your website into another section of the area, like: $_SESSION['section1'] = array(); $_SESSION['section2'] = array();
  10. Is it me or do you contradict yourself? You ask how you can password protect a page, but every time you open the page you are asked for a password?
  11. Remember that not all locale's may be supported. You can do: setlocale(LC_MONETARY, 'en_GB'); echo money_format('%n', $money); setlocale(LC_MONETARY', 'de_DE'); echo money_format('%n', $money);
  12. $w1 = 'hello'; $w2 = 'oelhl'; $p1 = array_sum(array_map('ord', str_split($w1))); $p2 = array_sum(array_map('ord', str_split($w2))); if ($p1 === $p2) { echo 'equal'; } else { echo 'not equal'; } //Output: equal function str2int($word) { return array_sum(array_map('ord', str_split($word))); } function word_is_like($word, $like) { return str2int($word) === str2int($like); } $match = $_GET['match']; $words = file('path/to/text/file.txt', FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES); foreach ($words as $word) { if (word_is_like($word, $match)) { echo $word, ' equals ', $match, "<br>\n"; } } [ot]Tell your teacher to come up with something more difficult[/ot]
  13. Depends if you mean from OpenID then no. If you mean through forms etc. then yes. OpenID provides an API for authentication, it only tells you the user successfully logged in. Depends if you mean, did you create valid OOP then almost. If you mean how you build up your class then no. Don't just create a class to wrap another. Your class should add functionality not copy. class My_MySQL { /*snip*/ public function fetchRow($mode = MYSQLI_ASSOC) { return mysqli_fetch_array($this->result, $mode); } public function fetchAll($mode = MYSQLI_ASSOC) { $rows = array(); while ($row = $this->fetchRow($mode)) $rows[] = $row; return $rows; } /*snip*/ }
  14. As developers we must learn to accept that our actions get people fired. Think of those many people a company would need to hire if they didn't had: 1) A CMS System 2) A CRM System 3) .. The process of manufacturing a car took a serious amount of people while now only a few are needed in the entire process as it's almost fully automated. And we call it progress? We are the root of all evil, as we automate more we will eventually make man itself obsolete. The Terminator told us in 1984 this would happen, but would we listen?
  15. Yeah I should have mentioned this, I noticed that the online service strips backward slashes (\) To avoid this you need to add another backward slash, like so (find \\s and \\n): function filter_duplicate($array) { return array_unique($array); } function explode_conditional($delimiter, $string, $conditional = array()) { return array_diff(explode($delimiter, $string), $conditional); } $bad = array('a', 'we', 'are', 'in', 'all', 'you', 'u', 'for', 'up', 'down'); $text1 = 'paintball tactical stock tippmann'; $text2 = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)'; $array1 = explode(' ', strtolower($text1)); $array2 = filter_duplicate(explode_conditional(' ', preg_replace('/[^a-z0-9"\\s]/i', '', strtolower($text2)), $bad)); $map = array_map('ucfirst', array_diff($array2, $array1)); $text1 = ucwords($text1); foreach ($map as $element) { echo $text1, ' ', $element, "<br/>\\n"; } Execute this code twice, once to see the output I got before and the second time to see your result so you know the script actually works. To use this script on your server you need not this one but the previous one.
  16. Why do you want a separate cookie in the /account/ section? Why not just use: $_SESSION['account'] for the /account/ section and $_SESSION[..] for whatever other section?
  17. I have checked this code on http://writecodeonline.com/php/ function filter_duplicate($array) { return array_unique($array); } function explode_conditional($delimiter, $string, $conditional = array()) { return array_diff(explode($delimiter, $string), $conditional); } $bad = array('a', 'we', 'are', 'in', 'all', 'you', 'u', 'for', 'up', 'down'); $text1 = 'paintball tactical stock tippmann'; $text2 = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)'; $array1 = explode(' ', strtolower($text1)); $array2 = filter_duplicate(explode_conditional(' ', preg_replace('/[^a-z0-9"\s]/i', '', strtolower($text2)), $bad)); $map = array_map('ucfirst', array_diff($array2, $array1)); $text1 = ucwords($text1); foreach ($map as $element) { echo $text1, ' ', $element, "<br/>\n"; } Returns
  18. How long does it average take before a computer problem is solved? Like I said you can set the DHCP server to lease the IP longer. PHP can't read out any other information and using JS to read out MAC addresses isn't the best approach either as JS can be disabled. Actually none of both methods are good in your situation, I would look into .NET as they allow communication with the Windows client with some imagination you can create something that will exactly pin-point the computer, like for example a big floor plan that visualizes every computer and lights up red when an error is reported.
  19. Either store session data in your database or extend the lifetime of your session. If they do press the log-out button you just destroy the session (cf session_destroy) or delete the database record. This is the better way.
  20. Which means JS which in my case is turned off.
  21. Matthew you are interpreting this wrong: As you have access to each computer you can set a static IP for each computer or set the DHCP server to lease an IP longer 1-week, 1-month, ... Get the IP of the computer using: $_SERVER['REMOTE_ADDR']
  22. Please read http://www.phpfreaks.com/forums/index.php/topic,297928.msg1411079.html#msg1411079
  23. It would be better if you used a database as you inevitably will end up using one. Remember: those files in which you store your data (eg XML) is also a database. This has the advantage that you don't have multiple sources that hold translation data.
  24. 1, 2: function filter_duplicate($array) { return array_diff($array, $array); } function explode_conditional($delimiter, $string, $conditional = array()) { return array_diff(explode($delimiter, $string), $conditional); } $bad = array('a', 'we', 'are', 'in', 'all', 'you', 'u', 'for', 'up', 'down'); $text1 = 'paintball tactical stock tippmann'; $text2 = 'TIPPMANN Sniper 16" Barrel (For 98 Custom and Custom Pro Markers)' $array1 = explode(' ', strtolower($text1)); $array2 = filter_duplicate(explode_conditional(' ', preg_replace('/[^a-z0-9"\s]/i', '', strtolower($text2)), $bad)); $map = array_map('ucfirst', array_diff($array2, $array1)); foreach ($map as $element) { echo $text1, ' ', $element, "<br/>\n"; } 3: Is this the output you want?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.