Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
What's wrong with the one I gave you? I tested it and it does match the emails you want: function test($email) { echo $email . ': '; if (preg_match('/^(?:\w+.?)+@(?:\w+.?)+$/', $email)) { echo 'valid'; } else { echo 'invalid'; } echo PHP_EOL; } test('test@test'); test('test.hello@test'); test('[email protected]'); test('[email protected]'); Output: test@test: valid test.hello@test: valid [email protected]: valid [email protected]: valid By the way, the PCRE functions (e.g. preg_match()) are faster than the POSIX regex functions (e.g. ereg()). Edit: Actually, it should be /^(?:\w+\.?)+@(?:\w+\.?)+$/ instead. Otherwise the period (.) will act as a metacharacter meaning "any character", but we want it to be a literal period.
-
I've used (and still use) Doctrine and I like it a lot. Especially the built-in support for the modified preorder tree traversal algorithm is pretty handy. Propel is another popular one, but I haven't used it myself. If I'm not too wrong then I believe that symfony uses propel.
-
Sending him a PM will probably not help very much. Does the book mention anything else about those files? I salvaged some other files needed in that book last day for a guy who emailed me. Chances are that the files you need are also stored on one of our servers.
-
Found this using Google: http://phprestsql.sourceforge.net/
-
You need a delimiter.
-
Because the syntax is user@hostname. Thus if the hostname is daniel-laptop and the user is daniel then the address would be daniel@daniel-laptop. If the hostname is gmail.com and the user is daniel.egeberg then the address is [email protected]. Simple, right? Example: daniel@daniel-laptop:~$ mail No mail for daniel daniel@daniel-laptop:~$ mail daniel@daniel-laptop Subject: Test Email This is a test Cc: daniel@daniel-laptop:~$ mail Mail version 8.1.2 01/15/2001. Type ? for help. "/var/mail/daniel": 1 message 1 new >N 1 daniel@daniel-lap Sun Aug 3 20:13 14/476 Test Email &
-
Try /^(?:\w+.?)+@(?:\w+.?)+$/
-
I'm not quite sure what the code is for. Also, for a function called get*() I'd expect it to return data, not output it. I don't understand what you mean. All include() (and require()) does is that it starts evaluating another file at the point where the call to include() is. You usually call such code pseudocode. Just saying
-
By only giving it to people you truly trust? Nothing you can do really. Large companies such as Microsoft and Adobe cannot protect themselves from piracy and the entire movie and music industry can't either, so how do you hope as a single person to do that?
-
Extending a class and getting the class name statically
Daniel0 replied to ravinggenius's topic in PHP Coding Help
It's not possible. You'll have to use late static binding which is only in 5.3 and 6.0. -
Crayon Violent, sprintf() doesn't make that possible. You'll have to write your own function. Here is a small one I wrote for this purpose: <?php function format($number) { $suffix = array('', 'K', 'M', 'B'); for($i = 0, $max = sizeof($suffix)-1; $i < $max; $i++) { $pos = strpos($number, '.'); if ($pos !== false) { $length = strlen(substr($number, 0, $pos)); } else { $length = strlen($number); } if ($length < 3) { break; } $number = round($number / 1000, 2); } return $number . $suffix[$i]; } echo format(3750000000); // output: 3.75B ?>
-
Try a layout like this: /application /controllers /views /scripts /index /index.phtml /library /Zend /public_html <-- document root /styles /style.css /index.php /.htaccess (etc.) It's better because you aren't storing things inside document root that doesn't belong there (see: http://www.phpfreaks.com/tutorial/php-security/page5) Also, how have you setup the rewrites? Not for us.
-
Either way, just remember that resources does not persist so you need to create them again using __wakeup().
-
It's a basic many-to-many relationship. branches branch_id, unsigned integer, primary key * etc. * students student_id, unsigned integer, primary key branch_id, unsigned integer, key * etc. * books book_id, unsigned integer, primary key * etc. * student_book student_id, unsigned integer, key book_id, unsigned integer, key created_at, datetime If Joe has user ID 142 then you can get his books like this: SELECT b.*, join.created_at AS book_given FROM books AS b INNER JOIN student_book AS join ON b.book_id = join.book_id WHERE join.student_id = 142;
-
You shouldn't do that. meta is not allowed inside noscript according to the DTD. Furthermore:
-
There is already another topic dedicated to this: http://www.phpfreaks.com/forums/index.php/topic,113931.0.html Surely you can find one you like in that topic. I'll just lock this to prevent additional topics about the exact same thing.
-
Uh, just copy the folder(s)/file(s) to somewhere else...
-
What, you mean like every other country on the planet? In some countries foreign copyrights are not valid because they haven't signed treaties requiring them to. http://en.wikipedia.org/wiki/List_of_parties_to_international_copyright_treaties That is why international copyright laws exist. Even if countries aren't responsible enough some papers, doesn't make it legal or ethcial for someone to fly to another country and copy your work. A country is only bound to an international law which the country itself has signed. As an example, in Iran it would be perfectly legal to "pirate" (which it then obviously isn't) Windows because it comes from another country and therefore is not covered by their laws concerning intellectual property.
-
You can only download (and index and search) the HTML, not the PHP code.
-
http://phpbench.com indicates that it doesn't matter much.
-
Me too. Especially seeing as Danish (my mother tongue) makes no distinction. Both words are translated to the same Danish word (hastighed).
-
Yeah, sure. Anyone who think they can eliminate that are ignorant, naive fools.