Re: [PHP] Help with this- pointers

2001-07-24 Thread Sean Cazzell

The $foo-bar() syntax is actually object references in PHP, not
pointers.  See the docs in the php manual regarding objects in PHP.


Kind Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Broken ip2long and long2ip?

2001-05-20 Thread Sean Cazzell

It appears that the integer type being used by these functions is not able
to store the entire 32 bits (4 bytes).  It can only handle up to 31 bits -
my guess is the type is signed when it should be unsigned.

In any case,I'm running PHP 4.0.5 on Linux 2.4.3 on an x86 machine.  I
would appreciate it if a someone can verify this before I submit it as a
bug.


Regards,

Sean Cazzell


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP's OO is bad?

2001-05-12 Thread Sean Cazzell

His series of articles (top php programming mistakes) is great, and
I've heard good things about his PHP Cookbook but Hughes is way off
here.  There is some additional overhead with OO code but there is *very*
little difference in speed (less than 5% in synthetic benchmarks, and
much less in more complex php code) - certainly not the signigicant slow
down that he claims.

IIRC, later in the article series, Hughes admits he isn't an OO fan, so
he's probably a bit biased.  Maybe he knows of some case where OO PHP code
runs really slow, but since he doesn't present any data to back up his
claims I suspect he just guessed that OO PHP would be slow (ie - he made
it up!).

I don't use OO for everything I do, but if the project is going to be over
1000 lines or so, I find OO code easier to maintain. YMMV.

For testing, I used two simple test files that both printed hello
world five times.  I did the benchmarking with ab (apache
bench).  The OO one:

?php
class bench {
function test () {
print hello world!;
}
}

$bo = new bench;

$bo-test();
$bo-test();
$bo-test();
$bo-test();
$bo-test();
?

The non-OO version is the same, but without the class stuff.  The non-OO
version averaged 580 req/s, while the OO version averaged 550 req/s.  This
was on a 600mhz pIII with 256megs of ram running Apache 1.3.19 and PHP
4.0.5 on a Linux 2.4.3 kernel.


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Sending attachments via mail()

2001-05-11 Thread Sean Cazzell

 I have some jpgs I'd like to send as attachments with automatically
 generated (via PHP) e-mails.  Does anyone have any suggestions as to how
 I might go about this?

Check this out: http://www.zend.com/codex.php?id=103single=1


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Encode/Decode Problem

2001-05-11 Thread Sean Cazzell

 I have a  in the middle of the encoded string. How can I solve this
 problem?

You need to use addslashes().

http://www.zend.com/manual/function.addslashes.php


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] protecting video files

2001-05-11 Thread Sean Cazzell

 which works fine until I add this at the top
 
 if($HTTP_REFERER != http://www.hardcorehosting.com/video/test.html;)
 {
 exit();
 }
 


Check to make sure $HTTP_REFERER is being set.  Just create another script
that has something like:

?php
print Referer: $HTTP_REFERER\n;
?

Then create a link to this new script from the test.html page that you're
trying to show the movie from.


Good luck,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Hidden Input and Quotes?

2001-05-11 Thread Sean Cazzell

 So my question is, should I (or, really, can I) encode it?  My thinking is I
 want to encode it with the htmlspecialchars() function... however,
 eventually, all the data within the Hidden Input Boxes will be stored into
 my mySQL database, so I'll want to decode it before I send it (restoring the
 quotes)... is there a way to decode the htmlspecialchars() function?

I ran into almost exactly the same problem.  I was about ready to break
down and hack out a regex when I came across the
get_html_translation_table() function.  This function lets you get the
translation table used for the htmlspecialchars and htmlentities
functions.  So, for example:

function my_htmlspecialchars ($string) {
$trans_table = get_html_translation_table (HTML_SPECIALCHARS);
return strtr($string, $trans_table);
}

This uses the strtr (STRing TRanslate) function to do the translation and
does exactly the same thing as php's native htmlspecialchars().  To
reverse things (replace the special chars with normal chars), we just need
to flip the $trans_table around

function strip_htmlspecialchars ($string) {
$trans_table = get_html_translation_table (HTML_SPECIALCHARS);
$trans_table = array_flip($trans_table);
return strtr($string, $trans_table);
}


There ya go :)


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] verify phone number

2001-05-11 Thread Sean Cazzell

 I am looking for code to verify a phone number has been entered correctly on
 a form field.  Requirements would include the area code:  xxx-xxx-.

You should use a regex for this.  Something like...

if (ereg ([0-9]{3}-[0-9]{3}-[0-9]{4}, $number)) {
print good\n;
} else {
print bad\n;
}

The regexp breaks down like this:

[0-9]{3}[0-9]{3}[0-9]{4}
(three numbers)-(three numbers)-(four numbers)

I didn't test the code above, so let me know if it won't work for you.


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] help with classes

2001-02-12 Thread Sean Cazzell

 So how does one correctly assign a variable to a variable inside a class withot 
doing something like:
 
 var $bar = '';
 $this-bar = $foo;
 

That's how you have to do it.


class MyClass {
var $bar;

// This is the class's constructor
sub MyClass () {
$this-bar = $foo;
}
}


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP, MySQL and XML

2001-02-05 Thread Sean Cazzell

Well, you're going to have to come up with a datamodel for storing the
parsed data.  You can parse RDF files with the XML extension, see the docs
at http://www.zend.com/manual/ref.xml.php

There are some classes on phpclasses.upperdesign.com which will handle RSS
files - you can probably look at these to get an idea of how to use the
XML module to parse RDF.


Regards,

Sean Cazzell


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] HTTP compression

2001-02-04 Thread Sean Cazzell

Alain,

When PHP parses a file, it treats the stuff that's not in ?php? blocks
as though each line were a print or echo statement.  So your whole file
will be compressed and sent to the browser.

Regards,

Sean

On Sun, 4 Feb 2001, Alain Fontaine wrote:

 Rasmus,
 
 Thanks for the clarification; it seems obvious, too, that mixing compressed
 and non compressed content would be quite difficult to implement; at least
 it would partially compromise the speed/size gain because of added protocol
 overhead.
 
 Now, imagining that we have enabled compression by calling
 ob_start("ob_gzhandler"), what happens for a document that contains
 something along these lines:
 
 !-- snip --
 ...
 ?
 // Enable HTTP compression
 ob_start("ob_gzhandler");
 
 // PHP content
 $content = "This is some content.";
 ?
 
 divThis is a normal HTML section/div
 
 ?
 // PHP content continues
 $content .= "And the rest of it.";
 echo $content;
 ?
 ...
 !-- snip --
 
 In this particular case, what would be compressed ? As far as I have
 understood, nothing at all, because some part of the output is not "passing
 through" PHP, right ?
 
  -Message d'origine-
  De : Rasmus Lerdorf [mailto:[EMAIL PROTECTED]]
  Envoye : dimanche 4 fevrier 2001 14:34
  A : Alain Fontaine
  Cc : [EMAIL PROTECTED]
  Objet : Re: [PHP] HTTP compression
 
 
   I've just started experimenting with ob_start("ob_gzhandler") a
  bit, and I
   have found that if any output is generated before ob_start() is called,
   nothing at all gets compressed; if ob_start() is called before
  any output,
   everything is compressed.
  
   Is this the case, I mean, is this "by design" ?
 
  Yes, it wouldn't really work any other way.  You can't mix non-compressed
  and compressed in the same request.
 
  -Rasmus
 
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] I should apologize

2001-02-04 Thread Sean Cazzell


 I don't mean to bash php in any way (as in the Ruby plugs in my last 
 post).  I use it because it has so many advantages over other more 
 system-oriented not web-oriented languages for this type of work.  It's 
 fantastic.

I don't think anyone will take offense to your mentioning the advantages
of another language (especially another open source language).  PHP
definately has it's worts and there's no point in sticking our heads in
the sand and pretending they are not there.

 I see so much enthusiasm on the web for this language, a significant 
 codebase, feature list (I'm not sure, but does ASP generate SWF files, 
 PDF files, support IMAP, etc), and it has a lot of great developers 
 dedicated to it.  But we need to be constantly self-critical, or we 
 won't see areas we can improve in.

Exactly.  If the volume of this list is any indicator, I'd say PHP has
grown quite a bit in the past six months.
 
 I also feel it's good to know more than one language, so you get more 
 than one approach and you're more adaptable to situations that PHP (or 
 whatever your language of choice may be) can't work in.

Definately.  Knowing Java or C will change the way your write code in Perl
or PHP (and vice versa).  I've written code in everything from ASM to toy
scripting languages (by "toy scripting languages", I mean the small
embedded scripting languages found in some applications - not PHP) and I'm
a better programmer because of it.

(Ruby does look very cool...I need to pick up the "Pragmatic Programmers
Guide to Ruby" - the guys that wrote it also wrote "The Pragmatic
Programmer" which is a great book.)


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Learning MySQL

2001-02-04 Thread Sean Cazzell

You need to go get yourself a copy of the MySQL book from New
Riders.  Stay away from the O'Reilly one, it sucks.


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] E-mail valid

2001-02-01 Thread Sean Cazzell

 Does anyone have a function that tells you weather a variable holds a valid
 e-mail address or not?

It depends on what you mean by "valid email address".  For example, I can
enter "[EMAIL PROTECTED]" which looks valid, but doesn't exist.  You can
take things a step further and lookup the domain and make sure it
exists.  Even then, I can enter "[EMAIL PROTECTED]" which will pass the
lookup check.  You can go even further and send me an email message with a
"key" which I must enter in order to prove that the email address I gave
is valid.  Even so, it is easy to create a throw-away account at hotmail
or another free email provider.

Anyway, there is a class on phpclasses.upperdesign.com that does a good
job of checking an address.


Regards,

Sean Cazzell


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] MySQL replication

2001-01-21 Thread Sean Cazzell

Andi,

No personal experience (yet), but there's a good article on phpbuilder
that you might want to take a look at if you haven't already:

http://www.phpbuilder.com/columns/tanoviceanu2912.php3


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] [php] - alphabetizing

2001-01-21 Thread Sean Cazzell

Ray,

You could create an array where the keys are the person names and the
values are the strings. For example:

$people_strings = array ("joe" = "bar", "andy" = "foo");
ksort($people_strings);
reset($people_strings);
while (list ($key, $value) = each ($people_strings)) {
print "$key - $value\n";
}

That should print out:

andy - foo
joe - bar

The ksort is the magic part, it sorts arrays by their keys.


Regards,

Sean Cazzell


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] XOR data encryption

2001-01-20 Thread Sean Cazzell

Steve,

If you're using MySQL, it has some built-in encryption functions that
would be slightly better than trying to implement XOR encryption in
PHP.  The best solution would be to use PGP or GPG (GNU Privacy Guard) to
encrypt the credit card numbers before you put them in the
database.


Regards,

Sean Cazzell


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] charactor problem

2001-01-20 Thread Sean Cazzell

 I grab this line and try to make it an array like this:
print "line: $thelinefromfile\n";   //Check the line
 $var1 = trim($thelinefromfile);
 $var2 = split(" ", $thelinefromfile);
 $count = count($var2);

Are you sure $thelinefromfile is actually being set correctly?


Regards,

Sean


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]