Search found 20 matches
- Sun Nov 06, 2005 2:11 pm
- Forum: Code Snippets
- Topic: IPv4 format validation
- Replies: 10
- Views: 15989
Using ip2long() is cheating though :lol: I was enjoying trying to write the code that usually sits under the hood, rather than looking for another way to do it in PHP. Its fascinating (to me at least) that what looks so simple can take so much thought and be so intriguing. Anyhow it gave me a nice h...
- Sun Nov 06, 2005 9:15 am
- Forum: PHP - Code
- Topic: Keeping html files private
- Replies: 3
- Views: 529
As the pages that can be accessed directly are HTML, PHP doesn't get involved so any security measures you take on those need to be done from the HTTP server. Simple basic authorisation using .htaccess (on Linux) or ACLs on Windows (removing the read permission for the IUSR_MACHINENAME for .HTM/HTML...
- Sun Nov 06, 2005 2:35 am
- Forum: PHP - Code
- Topic: Problems with classes
- Replies: 1
- Views: 148
- Sun Nov 06, 2005 1:50 am
- Forum: Code Snippets
- Topic: IPv4 format validation
- Replies: 10
- Views: 15989
This got me to thinking about the way we often forget that the various representations of an IP address are all just ways of writing a decimal value that can be up to 4294967295 (largest unsigned value in 32 bits). I sometimes like confusing friends by giving them addresses like this to visit http:/...
- Sat Nov 05, 2005 11:41 pm
- Forum: Code Snippets
- Topic: Prettying XML output
- Replies: 3
- Views: 12619
- Sat Nov 05, 2005 5:36 pm
- Forum: Code Snippets
- Topic: Prettying XML output
- Replies: 3
- Views: 12619
Prettying XML output
I just had need to pretty-format the output of DOMDocument->saveXML() for ease of reading, which comes as a string with no linefeeds or indentation of the XML. I thought I'd share the function in case others have need of something similar in the future; it took a while to get it settled, and it migh...
- Sat Nov 05, 2005 1:55 pm
- Forum: PHP - Code
- Topic: dynamically passing comparison operator
- Replies: 1
- Views: 180
Use an eval() on strlen($input_string) $comparison_operator $length so it looks something like this (not tested):
See PHP manual: eval
Code: Select all
eval("\$result = ".strlen($input_string)." $comparision_operator $length");
if($result) {
$valid = 1;- Sat Nov 05, 2005 11:35 am
- Forum: PHP - Code
- Topic: Finding part of a Variable..
- Replies: 4
- Views: 800
The kind of functionality you describe is commonly called browser sniffing or browser caps aka browser capabilities . There'll be libraries around that do that to varying degrees of sophistication. I've written my own limited code for detecting a specific (non-web) client using a regular expression,...
- Fri Nov 04, 2005 6:36 pm
- Forum: PHP - Code
- Topic: Better way to do it without using IDs?
- Replies: 23
- Views: 5236
- Fri Nov 04, 2005 6:13 pm
- Forum: PHP - Code
- Topic: Extending DOMElement *and* DOMDocument in PHP5?
- Replies: 4
- Views: 506
Yes, thats the way to do it. Let's just hope developers are disciplined enough to implement that design template in modular classes. I've had a discussion with the PHP developers today about these issues ( Bug 35104 ), and hopefully the documentation will have strong recommendations with a design te...
- Fri Nov 04, 2005 8:57 am
- Forum: PHP - Code
- Topic: Extending DOMElement *and* DOMDocument in PHP5?
- Replies: 4
- Views: 506
Unfortunately the work-around has severe drawbacks. Primarily because importNode() returns an object of the super class (DOMElement) rather than of the class passed to it - KMLElement. This is worse in that the new object doesn't have the functionality given it when it extended DOMElement. This appe...
- Fri Nov 04, 2005 7:44 am
- Forum: PHP - Code
- Topic: Got an error from mysqli_num_rows when trying to do a query.
- Replies: 5
- Views: 374
- Fri Nov 04, 2005 7:27 am
- Forum: PHP - Code
- Topic: Redirect
- Replies: 13
- Views: 696
- Fri Nov 04, 2005 7:21 am
- Forum: PHP - Code
- Topic: how to traverse a string
- Replies: 6
- Views: 540
You could use a simple regular expression:
What this does is replace all characters that don't match the range 0x20 - 0x7F (32 - 127).
Code: Select all
$subject = "the quick BROWN FOX \t 012345 $ \r\nthis is the next line";
echo preg_replace('/[^\x20-\x7F]/','', $subject);- Fri Nov 04, 2005 6:48 am
- Forum: PHP - Code
- Topic: Redirect
- Replies: 13
- Views: 696
Do you see those debugging echo statements? As far as PHP is concerned what they write is content and therefore headers are flushed. If you remove them the header() function calls will work as you expect. When debugging like this, its sometimes better to have a string variable that you add messages ...