Daniel0
Staff Alumni-
Posts
11,885 -
Joined
-
Last visited
Everything posted by Daniel0
-
What do you mean? If you output things, it'll be output verbatim. If you output things to a browser with an text/html MIME type it will ignore consecutive whitespace, however (check the source). You can use nl2br to convert line breaks (ASCII code 10) to (X)HTML line breaks. You can also use CSS rules to preserve whitespace.
-
echo date('r', strtotime('next Tuesday'));
-
Not really. What you're describing are name spaces. OOP is about modelling things using objects. Each object has a state represented by its properties, and the state of the world can be changed by calling an object's methods. As such objects interact with each other using each other's public interfaces, much like real world objects interact with each other in some sort of way.
-
I don't know anything about Indian law, but I would imagine that spreading malware with malicious intentions is illegal in India as well.
-
Perhaps you should just dump her if she is trying to infect your computer on purpose.
-
<?php $names = array("jack","john","Adam","Mike"); $numNames = count($names); $combinations = array(); foreach ($names as $name1) { $n1 = array_shift($names); foreach ($names as $name2) { $combinations[] = array($n1, $name2); } } print_r($combinations); Assuming order is irrelevant (i.e. "Jack John" is the same as "John Jack") and that a person cannot be combined with himself (e.g. "Jack Jack").
-
displaying email without attracting a ton of spam
Daniel0 replied to anatak's topic in Miscellaneous
I don't do anything to protect my email addresses really. Both my private and my PHP Freaks email should be pretty easy to find. The spam almost never makes it past Gmail's filters anyway. -
I believe that for filenames, everything past the first dot is considered the extension. You needn't worry about parsing paths though. There is a function called pathinfo that does this for you.
-
Really? I didn't get in till a couple years ago, a friend invited me, and I was in love... Now I wish I was in Wave Getting Google Wave now is not as significant as getting Gmail back when it was in a closed beta, IMO. Gmail was significant because it, amongst other things, introduced 1) a lot of storage compared to competitors, and 2) threaded email. It was built on top of the existing email protocols, so you can use Gmail with all other emails. If you have a Gmail you can communicate with everybody else who has any type of email. That is not the case with Google Wave. It's an entirely new protocol, and the number of people who have it isn't very big, so there are not very many people you can actually communicate with. Another problem is that the interface is unstable. I don't have a shit computer, but Google Wave seems very unstable with some of the large public waves. My Gmail can easily handle a conversation with 100 replies (which is the cut-off limit in Gmail by the way - after 100 replies it'll start a new conversation), but Wave doesn't even get up there before it gets sluggish. Google Wave still needs a lot of work, and it needs a much larger adoption before it's worth anything. Right now its utility is virtually non-existent and it's not much more than a cool toy. Gmail was immediately useful when you got it, but Google Wave isn't. tl;dr: It's overhyped and not anything special. You aren't missing out on much if you haven't got an invite. It's certainly not worth purchasing an invite for.
-
http://cgi.ebay.com/Google-Wave-Invite_W0QQitemZ280410438825QQcmdZViewItemQQptZUS_Software#ht_990wt_1165 $99?! Now I know what to do with my invites
-
I'm not sure I understand your question. If you need to use some information across multiple requests you should use sessions. http://www.phpfreaks.com/tutorial/sessions-and-cookies-adding-state-to-a-stateless-protocol
-
Yep. Actually, it can store binary files (like images), but I just meant that you should store the path to the file.
-
If you want to do that it would be wiser storing the information in a DBMS. Otherwise, the regular pagination techniques for databases would apply here as well: use an offset and a limit. It would quickly become inefficient without a DBMS.
-
I can see a potential use for it when "everybody" has got one, but right now I'm rather unimpressed.
-
Strange. Is there another field later on with the same name? If there is it will override it.
-
Turn off magic_quotes_gpc in php.ini. Which version of PHP are you using? It's turned off by default in PHP 5.
-
If it counts correctly then it gets inside the if. In that case you'll just have to adjust the echo and the $path variable at the top.
-
You could make a setter method that sets the upload path.
-
[SOLVED] Remove only line breaks between [code] [/code]
Daniel0 replied to Garrett's topic in Regex Help
You could use preg_split. $string = <<<EOF foo bar [code]test foo baz EOF; $newString = ''; foreach (preg_split('#\[/?code\]#', $string) as $i => $part) { if ($i % 2 == 0) { $newString .= nl2br($part); } else { $newString .= ' ' . $part . ' '; } } echo $newString;[/code] -
It's called id, not stock_id in your HTML source. Your code is really difficult to read because of the many echo'es. You should consider reformatting it.
-
Try posting the HTML source of your form.
-
PHP doesn't care either way. You can replace them with forward slashes if you want, but you can actually use a mixture of forward and backward slashes in paths.
-
Why would it be that unless you manually run something like addslashes() or mysql_real_escape_string()? (Or if you have magic quotes turned on, in which case you should turn it off)
-
Something simple like this should do it: <?php $path = '/images/'; $numImages = 0; foreach (new DirectoryIterator('/path/to/images') as $item) { if ($item->isFile() && in_array(pathinfo($item->getPathname(), PATHINFO_EXTENSION), array('png', 'jpg', 'gif'))) { echo "<img src='" . $path . $item->getFilename() . "'>"; ++$numImages; } } printf('There are %d images.', $numImages);
-
If all your pages are routed through a single file, a simple hack would be to define a constant called something like ROOT_PATH that contains the path of your application's root on the file system. A better way would be to use some sort of auto loader in an OO environment. If you care about micro optimization, absolute paths are also faster because the system doesn't need to resolve the real path. That's only an issue in large enterprise applications though.