[PHP] Re: PHP multi-threading ?
Eli schrieb: Is PHP gonna support multi-threading (not multi-processing) capabilities in the future? Not in the near future, sorry. Depending on what you are trying to implement: Ruby has multithreading. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Making Php Libraries
All attempts at shutting of access to the code is bound to fail. PHP is an interpreted anguage. If the script on the other server can read your code then the programmer of that script can also read your sourcecode. So, what to do? You could use some of the encoders. Using these tools the other people can still read the code but they'll find it too ugly to invest the work trying to understand it. But nothing keeps them from not even trying to understand it but just stealing it and using it as is. Nothing won. Then there's something from Zend that encodes your file so that it CAN'T be read as source code. A normal server can't even execute it. Your users will have to install some runtime module. The encoder isn't free, the runtime is. This stuff even allows for expiring licenses if I recall correctly. So you could give the code to your users and still you won't loose control over it. Finally: Why give users access to your code? Why don't you just let them use it in a specified way? Donig so is called defining a PROTOCOL. give your users exact specifications of what they may call and what they'll get back. There are even big enterprise-oh-my-god-complicated solutions for calling code remotely, with SOAP and the .NET web services being the most prominent ones. There's SOAP support in PHP so you might want to snoop at that. OK, gotta sleep ;-) OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Is this the most effient to do with php an mysql?
Paul Goepfert schrieb: Is there a more efficient way to do this using more PHP and less mysql? Anything that helps you inside SQL to get your solution doing just one statement should be faster than doing two queries with some PHP code inbetween for reasonable complicated tasks. This is because the time overheads for using the connection and the socket overhead are bigger than the time won by doing the intermediate calculation a bit better with PHP. So, if your SQL looks somehow similar to what you would do on the PHP side: Keep it that way! OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Window close.
Just for the laugh: You could send a redirection to a page that causes the browser to crash ;-) No client side scripting involved *g*. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: I have stange problem
Some other program blocking the port? Skype is known to cause trouble when the port 80/443 as fallback option is activated (which is the default). Of course, many other programs might cause such problems. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: what is better for performance?
Karel Kozlik schrieb: Hi, I am just thinking about that what is better for storeing structured variables in point of view of performance. Is better store structured variables in associative array, for example: $person['first_name'] = 'Karel'; $person['last_name'] = 'Kozlik'; $person['address'] = 'somewhere on Earth'; or in object like this: $person-first_name = 'Karel'; $person-last_name = 'Kozlik'; $person-address = 'somewhere on Earth'; I feel that objects are better for performance, but work with associative arrays is pleasanter for me. May be the diference in performance measurable? (in heavy loaded environment) First of all: You are already using something like eAccelerator? You have optimized your database queries to take full advantage of the query cache in your DBMS? You are using a userland cache to increase the performance for seldomly changing content? If the question is No to these or similar questions: Don't waste your time on thinking about performance differences in the microsecond range! Unless your site really has to take some hundred thousand page requests a day this is just silly. Now for the concept of array vs. attributes: I used to prefer the array notation, too. But think about this: Arrays suggest some similarity between the array elements, it suggest the elements are somewhat of the same type. On the other side attributes are just that: Attributes of an entity. So, it's more appropriate to use array notation for a collections of persons but not for the attributes of a single person. This started to change my mind about using array syntax here. Besides, using - saves you two keystrokes/bytes. OK, that was for conceptual view. Now technical ;-) The performance depends on the version of PHP you are using. For PHP4, classes and objects are very much like arrays in disguise, it's only with the Zend Engine 2 of PHP5 that this has changed. This engine has greatly improved performance in PHP 5.1, so yeah, with PHP5.1 attributes could be quicker than arrays BUT you shouldn't care ;-) But remember: Always prefer concept to performance when designing software. Performance considerations are welcome and important for the large scale (as in you shouldn't fetch all the rows in a table if you display only ten of them = use LIMIT) but micro-profiling is definitely something you should do when the system's up and running. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Lowest PHP version to work with MySQL 4.1.x
AmirBehzad Eslami schrieb: I have noted that some versions of PHP are unable to work with MySQL 4.1.x. Would be new to me but... 1) Should I upgrade to PHP 5? Disregarding your question about databases: Yes you should. PHP5 is there since well over a year. The dev team WILL stop support for PHP4, be it sooner or later. With the 5.1 release there are no speed arguments for PHP4 anymore. If you switch now, you are avoiding bigger adjustment problems in the future. 2) What is the lowest PHP version which works fine with MySQL 4.1.x? Tip: Look at the relase notes of the different XAMPP versions. They always bundle a PHP4 version with a MySQL version and they have changed to MySQL 4.1 very early. Any download they offer means that the contained versions work well together. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: When to make a class
Todd Cary schrieb: My background is in Object Oriented Pascal (Delphi), however I am having difficulty knowing when to make a class in PHP. For instance, in my script file, functions.php, I have these functions among others: /* Input a field */ function input_field($name, $value, $size, $max) { echo('INPUT TYPE=text NAME=' . $name . ' VALUE=' . $value . ' SIZE=' . $size . ' MAXLENGTH=' . $max . ''); }; /* Input a password field */ function input_password_field($name, $value, $size, $max) { echo('INPUT TYPE=password NAME=' . $name . ' VALUE=' . $value . ' SIZE=' . $size . ' MAXLENGTH=' . $max . ''); }; Should I have a class that contains these functions (methods)? Simple answer: If YOU don't see the benefits of a class then you shouldn't use one. Longer answer: I see the benefits of a class when functions start sharing variables. Then you would have to use $GLOBALS or the global keyword. This is a big indication that the functions should instead be inside a class and that the variables should be properties of that class. Of course, when you start using classes you slowly move to using classes even if they're not absolutely necessary as with your two functions up there. Then one notices that there are even more types of input fields (radio buttons, hidden fields, select boxes...) and that they have something in common (attributes of the input tag). So one could think Hey, why not make a base class for all fields?. And so on... OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Any performance experiences to offer?
Tim Meader schrieb: Was PHP5 faster than PHP4 for identical code? Thus making PHP5.1 even faster? Or was it a case of PHP5 being a bit more bulky than PHP4, thus PHP5.1 bringing it more inline with the old performance. I'm looking to upgrade of PHP 4.4.1 installs, but I'm holding off on PHP5.1 until eaccelerator (open source PHP accelerator) becomes compatible. As it is, PHP5.0.5 is the last supported version. But if 5.0.5 is slower than 4.4.1, I'll hold off. That depends... For typical PHP4 applications (little to no class stuff) I've heard of benchmarks showing PHP5 to be slower than PHP4. These issues should be fixed with the 5.1 release. If you intend to make use of OOP features then PHP5 is not only faster but a lot of them simply aren't available with PHP4. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: calling static methods of variable class names
Ahmed Saad schrieb: hi all, how can i call static methods of a class whose name is variable.. something like ? $className::doSomething(); // throws a parser error ? I can do this with reflection by creating a ReflectionMethod object then invoke()ing it, but is there a better way? Thanks -ahmed For $args=array('para1','para2'); use call_user_func(array($className,'doSomething'),$args[0],$args[1]); or call_user_func_array(array($className,'doSomething'),$args); Have Fun! OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php5 call by refference
Georgi Ivanov schrieb: Hi, AFAIK, in PHP5 one can't call function with function parameters . The error is that you only can pass variables by reference. foo(strlen('aaa'),strlen('')); Is there some sort of workaround ? First of all, the problem with this arises if your function foo is defined as function foo($a,$b) { ... } There is no problem if a and b are not reference parameters. So think a second about this: You tell in the definition of foo that you want to write to the position where a and b are stored. But by calling the funtion with strlen() you don't have a position in user space because the results of strlen() are just values which haven't been explicitly stored. Now you can decide if you don't write to your parameters a and b. Then there is no need for call by reference! It is not true that PHP copies the value and that you save memory by using references! The values of call-by-value parameters are copied if and only if you WRITE to them! The Zend Engine 2 is highly optimized for this. If you want to write to a and/or b then you must supply a storage container (also called variable *g*). Simplest way of supplying a temporary container: foo($t1=strlen('aaa'),$t2=strlen('')); Have Fun! OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Deployment and maintenance of php software
Andy Pieters schrieb: Is there anyone that can provide a solution to this or suggest another approach to the problem? First of all something about packages: PEAR is coming up with their own format .phar for this. These are tar archives that may contain an additional PHP script that is executed when unpacking the archive. This gives you all the possibilities of other package management systems. If you decide to go for standard package formats: I can't tell you anything about .rpm but I know that it isn't too difficult to build .deb packages. There are good howtos for the debian format. As another approach: How about using Subversion? PHP developers have one advantage: They don't have to compile their code before deployment. So in other words: Deployment is somehow very similar to just getting the source code. Subversion on Apache allows for easy access control. You cann create a deployment branch or even different branches for each of your customers. After you have created some new features in your project you can simply merge the changes to your braches. All the client has to do to fetch this update is one single svn up! OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: echo
Alex Alfonso schrieb: echo I need a space here; echo space; *g* -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php5 / php4 - MySQL/SQLite
Danny schrieb: Let me open a discussion about php5 / php4 Fine. Let's keep it short ;-) Why upgrade? Because you want support for proper OOP. Most of the other changes can be like SQLite can also be used with PHP4. It worth? If you see the benefits of interfaces, object overloading, autoloaders, interceptors and/or exceptions: yes. If you want to do some simple stuff:no. If you are starting to implement a large project: big yes. Benefits? Example: I have a simple object-layer for my databases and relations. If I have a table MEETING and a table USER and I have a reference table for the USERS_IN_MEETING, then I can now $m=new DB_Meeting(12); // simply by id, other criteria possible foreach ($m-allAttendees as $user) { mail($user['email'],'Invitation','Meeting: '.$m['description']); } That's it! No queries, no nothing. And thanks to interceptors I could implement this in very few lines of code. Code programming changes? I doubt any of my new PHP5 code can be backported or properly simulated in PHP4. If you really get into it, there are big changes on the horizon. But if you want to keep programming the way you did: Nobody keeps you from continuing this way with PHP5. Is there and end-of-life for php4, in the near/medium future? I don't believe in that. There will certainly be no new features for the PHP4 branch, but it will get security updates for quite some time and hosting companies will continue to feature it for years to come. What about MySQL and SQLite. What is the future of both? I would like to open a discussion about the future of both related to php no matter the version of it... SQLite: This is no comparison to MySQL because I think it fits totally different problems. It's easier to use than MySQL because you don't have to connect to a server. You can simply deploy the database as a file with your application. But it is not as good when it comes to high concurrency (meaning a lot of visitors). So: - SQLite for small projects that are used by few users. - MySQL for big web sites. MySQL: Even if you stay with PHP4, please consider switching to the mysqli objects. One benefit: They are more like the SQLite API so you can get some synergy when learning both of them. For PHP5: PHP5.1 will feature the first final version of PDO. PDO allows to use MySQL and SQLite via one interface. OLLi Kajiggers! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: php session variables limited to 1 character -- please help
Zac Smith schrieb: http://www.triptrivia.com/step2-debug.php?State=abc 404 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: moving website from windows to linux hosting
pedro mpa schrieb: (Like changing directory paths from \ to / ). Ahem... shouldn't you havee used / on the Windows machine, too? The \ comes from the DOS era of the Windows OS, but the / is the world standard and Windows Servers perfectly work with /. Even the Windows explorer is able to translate / to \. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How to read word document by php script
Roman Duriancik schrieb: How can I read data from word document (*.doc) use by php script ? I konw only how to write and how to open word document. Convert the .doc to a .txt document before opening it with PHP. There are external tools available to do this but I won't do the searching for you ;-) OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Abstract Classes?
GamblerZG schrieb: But what benefit is there is having it as an explicitly abstract class? Why can't it just be a normal class definition which you inherit from? The idea is that a high-level language should prohobit you from doing things that do not make sence. Why they implemented it in PHP? Because it's there in Java, I guess. No, it's there because it makes sense. If you derive from an abstract class the mechanism forces you to implement the abstract methods. Think of this: class Super { public function check() {} //no code! public function huba() { /* code */ $this-check(); // use of method } } class MyClass extends Super {} This is what you do without having abstract classes. You put an empty method into the class. You rely on remembering that test() has to be filled with meaning in the subclass. You are even allowed to forget implementing check() which might get you into trouble because the check() is what you meant to be called for ensuring the data integrity of the data you intend to use a few lines later. Or worse: You leave out the method in the superclasse and only state in the documentation that there has to be a check() method in subclasses. This is the way to forgetting to implement all kinds of stuff. So there is this mechanism called abstract class: abstract class Super { abstract public function check(); public function huba() { /* code */ $this-check(); // use of method } } class MyClass extends Super {} Now, you enforce several things: - Super cannot be instantiated. It is not complete and PHP knows about this. - MyClass is not complete until you implement a check(). This way you have to actively say I don't need a check. by putting an empty check() into MyClass. Even better: You can decide to implement just some of the abstract methods of Super. Then PHP forces you to declare your subclass as abstract, too. This allows for partially complete class trees and it is not up to you to remember which classes are ready to use and which are not. No, abstract classes are not just there because Java has them, they exits because they help you in managing your code repository and because they prohibit you from doing stupid things with the code. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How can I count the usage of mail function in scripts?
Andy Pieters schrieb: While it *is* possible to do what you ask for, it would be worthless. I can write from scratch a php script that * looks up the mx record for a given email address * connects to the mail server looked up * send the message. Since the SMTP protocol is fairly simple, I am sure many others can and will use this to circumvent your limitations. And with PHPMailer there's a package that does this work for you ;-) As I said: What I do with my traffic is none of the hoster's business. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Classes or functions
I'd say it depends on the size of your project and on any plans to reuse the code. Classes are better suited for building libraries of code you use in other projects. And any large project runs into problems with function names if the programmer doesn't use a rigorous naming system (like function package_subpackage_functionname() { ... }) and if such names are used one could just as good use classes. Technical difference: Functions are a little bit faster (think of PHP having to look just one time instead of one time for findeing the class and one time for finding the method). Depending on PHP version: PHP4 has an affinity to using functions because the classes are not as mature and full-featured as in PHP5. So: with PHP4, you actively have to choose using classes; with PHP5, you want to use classes. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: file_exists()
Jonny Bergström schrieb: Hi file_exists('字.gif') always returns false. Can anyone help me find out a way to make it work also for these kind of filenames? Unicode filenames can't be properly handled up to now for all I know. Perhaps waiting for PHP6 might be your only solution. OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: file_exists()
Robert Cummings schrieb: You could try execing a shell command to give you the answer. I don't know if it'll work, but worth a shot if you're in a bind. Yep, good idea. Use the native code of the OS ofr listing the file (dir, ls...) and parse the result. OLLi Manche sagen, Computer seien besser als Menschen - aber viel Spaß im Leben haben sie nicht. [Peter Ustinov] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How can I count the usage of mail function in scripts?
Cristea Adrian schrieb: Hello peoples! short question: How can I count the usage of mail function in scripts? long description :D I have a webserver, and I want to limit the usage of mail function for each host I have there.. Notice that i have a couple of hundrest of virtual hosts (domains and subdomains) there, and i want to limit them, let`s say.. 100 mails per day.. there is any solution to do that? (i know there is, i saw that in a nwebhosting company) .. can you guide me find this solution? This is not a PHP problem. The mail() function just uses the mail server of the system it is running on. There are several solutions to the problem. For exmaple: If you could configure your server so that the user's PHP scripts run under their user ID (chroot/CGI), you can use the normal mail quota system. And: No, I can't help you any further on this. OLLi Mal: You only gotta scare him. Jayna: Pain is scary... [firefly] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: How can I count the usage of mail function in scripts?
One more point: If I were your customer and you'd deploy such restrictions, I would leave you. Usually customers pay a fix fee for some free traffic and then must pay for traffic exceeding those limits. What they do with that traffic is none of your business. There are a lot of companies sending out newsletters in a mothly fashion to all of their 2 users who requested to get that newsletter... OLLi Time continues to skip forward randomly. Details at eleven...This is the news at eleven. The mysterious and unexplained... Turning to Entertainment News. Teen Singer Wendy might just be the latest... won three Emmies last night...found dead in her bathtub. [Futurama 314] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: asynchronous PHP to PHP call
James schrieb: I have a PHP script running on server 1. I want it to call another script on server 2 to clean up some files. There may be tons of files and I don't want to wait until the second script is finished. Is there a way to asynchronously call the second PHP script? Right now I'm using fopen() to call the script on the second server. Other option: Don't let the called script on server 2 do the work. Use it to start another phpcli-script, then immediately send out the answer. Something like ?php exec('/usr/bin/php cleanup.php '); echo 'Cleanup started.'; ? OLLi To the optimist, the glass is half full. To the pessimist, the glass is half empty. To the engineer, the glass is twice as big as it needs to be. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Inserting NULL Integer Values
Shaun schrieb: $qid = mysql_query('INSERT INTO MYTABLE ( column1, column2, ) VALUES ( '.$value1.', '.$value2.' )'); A bit off-topic but important: Always make sure that you check the contents of $value1 and $value2 before putting them into the query! With $value1 = 'xyz,xyz); DELETE FROM MYTABLE;'; you might get surprising results! This is called SQL injection and it's important to escape all the values before putting them into the statement. An even better solution are prepared statements! With PDO (available as an extension for PHP 5.x) these are natively supported. You prepare the statements without any of the values and call them with the values. The engine automatically escapes your data. OLLi Bug? That's not a bug, that's a feature. [T. John Wendel] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: How can I count the usage of mail function in scripts?
Greg Donald schrieb: On 10/18/05, Oliver Grätz [EMAIL PROTECTED] wrote: Usually customers pay a fix fee for some free traffic and then must pay for traffic exceeding those limits. What they do with that traffic is none of your business. You've obviously never been a hosting provider. Did I say that? I was talking about being a customer. The type of content that might be forbidden in some countries is off topic. The question deals with restricting the amount of mails a customer may send in a certain amount of time. This is what I mean by none of his business. I simply spoke of what the provider puts in the contract and on this point the provider guarantees it's customers something like 50GB free traffic with a fee of 49ct for each GB of traffic exceeding this limit. Nothing about any restrictions on the amount of data of a certain type. If the provider decides to limit the amount of mails per day to 100 the why not limiting the amount of web pages served to 500? Or not more than 20 files per directory? Or may not serve GIF images? Such restrictions are simply ridiculous. OLLi All Glory to the Hypno-Toad! [Futurama 307] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Recommended Reading?
From a practical view: *For big web projects:* Make a plan! Do not start to write code before you exactly know what you want to do. An important concept in the development of large web applications is the MVC princinple (Model View Controller) which basically urges you to seperate the data and the display. Get an insight into MVC, it will help you in designing your application and it will come in handy if you decide to implement more ways of displaying your data than you thought of in the first place. *For a certain problem:* Do not reinvent the wheel! PHP is a language with a really large function library. The amount of extensions that are directly available is so high that chances are good you'll find a solution right there as a function ready to use. So: Dig through the documentation at php.net! Learn what extensions there are. Use the comments in the documentation, they provide valuable examples. If you can't solve your problem with the internal functions: Search the web! The PEAR repository offers a lot of packages solving a lot of problems BUT they are not always the best solution. Projects like AdoDB, Propel etc. show that there are often more solutions than you wanted. So do not compromise too much: If a solution does not exactly fit your needs, continue the search. *For the next project:* DRY (Don't repeat yourself)! Code you've written once can come in handy for the next project. So start to seperate the code you write into application specific code and library code. You can reuse your library for all of your projects. *For any large development:* It's a good idea to use a versioning system. Subversion is free and ready to install on any Apache server. With PHP it's also an ideal solution for deployment: Just make a release tag and check it out on your production server. Add some config and off you go! Happy Development! OLLi You see, Mr. President: The worlds hates America. And for good reason. (I wont bother going into details) [24 319] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: RegEx - Is this right?
I don't know if these are equal. What about \r\n line endings? And what about \r line endings (from old Macs)? I guess file() handles all of these cases (didn't test it though) and your code doesn't (with \r you'll get a one line file!). AllOlli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Question about including files and server load
Jay Paulson schrieb: function xyz($abc) { return include(xyz_func.php); } function abc($xyz) { return include(abc_func.php); } Oh. My. God. Is this ugly. OK, it works, but that's not the way how one should abuse include(). I was wondering isn't this putting a bigger load on a server by including so many files for each function? Also, I was wondering what everyone's opinion was on this approach in terms of maintenance. Do you think it's better practice to put all your functions in one file or do it in this manner? First of all: Yes, it increases the load, but not as much as one might think. Modern filesystems are pretty good at caching so after the first access to your scripts after some pause (caches cleared) there is a big overhead but for subsequent page requests the overhead will be almost negligible. So: Favor well organised file collections over big bloated single-file function libraries! But: Don't do it this way! Group the functions into similar ones (e.g all functions regarding mail into functions/mail.php) and put each group in one file. Rule of thumb: Starting at over 500 lines you begin to get more problems at maintaining your script files. Then it makes sense not only grouping the functions into one file per function group but into directories containing one to many files (e.g. functions/mail/send.php and functions/mail/receive.php). Following this you should of course start to not include your whole function library in each request but to implement some library loader. You could do this in your pages: // your index.php (if using this for all pages) or something // you include in each file // this is a page sending html mails so I need this: $used_libs=array('mail/send','html/create'); foreach ($used_libs as $lib) { include('functions/'.$lib.'.php'); } You could extend this concept to check if the requested files exist and you could add some array with libraries that you want always to be included. You could also create a mail/all mechanism that includes all of the files in one directory. And with PHP5 you have even more choices. You could use classes instead of functions. Even if you don't want to instantiate objects you could use them as namespace simulators in a static way. Instead of function mail_send() {} you could write class Mail { public static function send() {} } This would then be called via Mail::send(). What's the advantage? Well, you can cretae an autoloader for classes with PHP5. If you write it so that the class Mail is in the file classes/Mail.php then you can autoload the class on access so you can Mail::send() without having to explicitly include anything! Youd wouldn't have to configure your scripts since only those classes you use will be included. This of course reduces your server load. So, long enough a response ? ;-) AllOLLi 6: Dr. Amrak gave the disc to me before he died. B: What? As opposed to after he died? [Battlestar Galactica 107] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: test
Ignored. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: include file to global scope
Claudio schrieb: I'm using PHP 5. I have a class operation that includes php files. Is there a way to include this files to global scope? So that difined vars and functions are global accesseble? I know this problem from my early PHP days. If your problem is that you want to include some class or function libraries then the simple solution is: Do not include inside the function or class but let the class or function just return the path name! So instead of function include_lib($name) { $path='functions/'.$name.'.php'; // or more werid stuff include($path); } include_lib('test'); do function lib_path($name) { $path='functions/'.$name.'.php'; // or more werid stuff return $path; } include(lib_path('test')); Perhaps your problem is exactly of this type or similar. AllOLLi Inara: It sounds like the sort of thing this crew can handle. I can't guarantee they'll handle it particularly well, but... Nandi: If they got guns, and brains at all... Inara: They've got guns. [firefly 113] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Obsession with BC
GamblerZG schrieb: Recently, I asked my hosting provider when they are going to switch to PHP5. They replied that it will not happen any time soon, since they will install PHP5 only on new servers. Their reasoning was simple: PHP5 will inevitably break some old scripts, and it's just not worh all the trouble. Must be the same reason why we are all still using DOS since some of the best games just refuse to run on WinXP !? Noo... There are a whole lot of new scripts that don't work with PHP4 so I guess chances are the problem is already bigger in this direction (PHP5 code not running on PHP4) than in the other. The provider arguments are FALSE! If they don't want to break old scripts they can easily deploy both PHP4 and PHP5 as parallel installation, either one of them as CGI or by using two Apache servers and a proxy. The real arguemnts for the providers are a) They are too lazy to do this b) Two PHP versions in parallel might need more computing power which they refuse to invest for AllOLLi The answer is 42. [Douglas Adams] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Obsession with BC, take 2
Robert Cummings schrieb: You can use separate engines. The topic has been addresses many times already. Set up a second instance of apache and use the ProxyPass system to pass control from the primary apache server to a PHP5 enabled apache server. I always thought this complexity is why people are not doing this. I read about patching the PHP5 sources so the internal names for the module do not collide with those for PHP4. Then it's possible for bothe modules to coexist in a single Apache instance. Why ist this not made standard behaviour? Oliver Zaan: There is much cruelty in the universe. John: Yea, We seem to have the treasure map to it [FarScape 121] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Sequential multiple file download?
This can't be easily done. The natural way of doing this would involve sending some HTTP headers but this is not possible once you've started sending data for the first file. The hard way of doing this is a 2-way approach where you have two connections: a data connection and a control connection. This of course requires you to use JavaScript. The control connection to the server would periodically be asking if sending a download has finished. This could be done with Ajax techniques and some kind of server side database or session store for the information about the finished downloads. The other connection would then be triggered as a redirect from JavaScript that fires up another download. Of course there might be other solutions but none of them are really easy to implement. If you are targeting a closed audience you might change your approach to sending some kind of download list that triggers a download manager. AllOLLi Byers: What proof do you have? Bond: I got this! Byers: You're on the phone, Jimmy! [Lone Gunmen 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Store a variable name in a database field.
Yep, code sample, please. Your question is not describing your problem clearly enough. OLLi If at first you don't succeed, call it version 1.0 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] storing passwords in $_SESSION
Dan Brow schrieb: Thanks, figured that would be the case. Can't for life of me think why I wanted to do that, must have had a brain infarction. I want to have an expired session prompt so people can log back in with out having to start at the login page. Would having the users login saved in $_SESSION be alright? prompt them for their password and compare it with the password in the DB be fine? I want to reduce the amount of typing someone has to do when a session expires. Why don't you leave the decision if they want to type to the user? My browser keeps track of what I entered into every login form I ever visited... AllOLLi We'll draw straws. They're coming. We don't have time to argue about who gets to risk their life. [Locke on LOST 124] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Non-Javascript PHP Onsubmit function?
Jasper Bryant-Greene schrieb: I disagree. Best solution: Don't use a confirmation thing, provide the ability to undo changes instead. That way you don't piss off the advanced users who KNOW what they're doing, but you still allow the less advanced users to undo changes they accidentally make. Oh, changing the concept was on the menu? Me too,please ;-) OLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Global unavailable?
Problem not reproducable. Test case used: --- a.inc.php: ?php $a = 123; --- b.inc.php: ?php require 'a.inc.php'; class b { function test() { global $a; echo $a; } } --- t.php: ?php require 'b.inc.php'; $x=new b(); $x-test(); --- Command line: php t.php Output: 123 I used PHP-5.1 RC1. No problem whatsoever. Such problems shouldn't arise in new versions since they are touching very basic concepts that didn't change. AllOLLi You see, Mr. President: The worlds hates America. And for good reason. (I wont bother going into details) [24 319] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Non-Javascript PHP Onsubmit function?
zzapper schrieb: Hi, I'd like to have a non-Javascript based general purpose Are you quite Sure? PHP form submitter, conventionally done using the Javascript Onsubmit Event. One way would be to store all the Form Variables in hidden fields generated by a foreach $_POST but anyone have anything simpler? How about the user saying no? You would have to return to the form page and repopulate the form with the data. So not storing the data in a usable format is not an option. Here's a dirty hack: How about displaying the same form in a hidden DIV? OK, that one was cruel... A better one: You could fetch the RAW post data and store it in the session. Problems arise when there's more than one window open! Use a unique ID for the form. Best solution: Use the hidden fields! AllOLLi Sidney: Are you sure you don't wanna stay for dinner. Eric: I'd love to but... I gotta save the world. [Alias 402] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Dynamic sub directory listing without redirect
http://httpd.apache.org/docs/2.0/misc/rewriteguide.html AllOLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP5 OOP how do I get the list of all classes dynamically?
You can get an array of all declared classes with http://de.php.net/manual/en/function.get-declared-classes.php If you need more context (e.g. only subclasses of X) you should definitely have a close look at the reflection api. AllOLLi Being lectured by the President on fiscal responsibility is like Tony Soprano talking to me about law and order [Sen. John Kerry, 3rd debate] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 Hosting
Sheesh! No week passing by without people complaining about hosters missiong out on PHP5. This is one point where we in Germany seem to be lucky. The two biggest german hosters 11 (about 4 million domains) and Strato (about 2.5 million domains) both offer SSH and the possibility to chosse the PHP version on a per directory basis (via .htaccess). Strato offers PHP 3.x, 4.0.x, 4.3.x and 5.0.x in parallel. Perhaps you should think about outsourcing your hosting *g*. For about 13 EUR per month you get PHP3, 4, 5 and even Ruby, SSH access, MySQL access, 4 Domains, 600MB space and 30 GB free traffic. AllOLLi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP 5 Hosting
Torgny Bjers schrieb: I am assuming they're running PHP through CGI in this case, am I correct, or are they hosting on Windows to achieve the multiple PHP versions? If CGI, that rather affects performance of larger applications, it especially impact render time of more complex templates and forms. During my own testing we gained lots of time by just running it as a compiled Apache module instead of through CGI and in .htaccess. Well, I guess you are right. One can compile multiple versions of PHP to run as Apache module in parallel by changing the sources (one has to change some symbol names) but I think Strato didn't do that since most shared hosting services run PHP as CGI anway for security reasons. Also, I think writing applications with high performance requirements somewhat contradicts deploying them on shared hosts. If you need performance: Get a dedicated server and - if you want - even compile yer own hand-optimized PHP. And: Clever development circumvents the CGI bottleneck. Developing is absolutely no problem under CGI since it's done by just a few users and here the flexibility of multiple version kicks in: You can freely choose! For the production version you simply use a good userland cache that minimizes the work done by PHP. AllOLLi Bree: Do you know, I’ve finally convinced Rex to buy his first orchid. George: Make sure you study up. I hate people who own precious flowers and don’t know how to take proper care of them. Rex: You know what I hate? Weeds. They just pop up out of nowhere and you have to work so hard to get rid of them. George: I find that with the right chemicals you can get rid of anything. [DH 120, earns the price for most subtext per sentence.] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: RecursiveIteratorIterator för PHP 5.0 .5 Win32
Erik Franzén schrieb: Fatal error: CMAES_DomIterator cannot implement RecursiveIteratorIterator - it is not an interface ... Does not PHP 5.0.5 support the RecursiveIteratorIterator Interface? No, it doesn't. Like it tells you: RecursiveItraorIterator is no an interface. It's a class. You can extend it but not implement it. Further info here: http://www.php.net/~helly/php/ext/spl/ AllOLLi Buffy: The Slayer.. The chosen one. She-who-hangs-out-a-lot-in-cemeteries. [Buffy 411] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: array_shift not working?
Frank Keessen schrieb: Can you please help me with the following This is in the array($info[0][bdnadvocaat]) Array ( [count] = 2 [0] = 210 [1] = 149 ) This is the code: $testje=array($info[0][bdnadvocaat]); $test=array_shift($testje); print_r($test); This is the output Array ( [count] = 2 [0] = 210 [1] = 149 ) How can i remove the 'count' from the array? array_shift works in situ, it operates on the array insted of returning a new one. Also you are using array(), whichs builds an array of its argument(s). Suppose you have Array ( [count] = 2 [0] = 210 [1] = 149 ) in $info[0][bdnadvocaat]. Then $testje=array($info[0][bdnadvocaat]); will result in having Array ( [0] = Array( [count] = 2 [0] = 210 [1] = 149 )) in $testje. An array with just one value! Afterwards doing $test=array_shift($testje); will remove the first element from $test and give it as result. Afterwards you have $test == Array ( [count] = 2 [0] = 210 [1] = 149 ) $testje == Array ( ) If you simply want to remove the first element from $info[0][bdnadvocaat], you can simply array_shift($info[0][bdnadvocaat]) which removes count. AllOLLi That fact was conveniently omitted. [Enterprise 409] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: why does this not work?
Ross schrieb: $width = script document.write(screen.width); /script; //$ross= intval($width); Yes, this is and will always be zero, because you are evaluating a string to an integer value. echo $width; if ($width 1064) { echo lower; $style= style1.css; } else { $style= style2.css; } OK, no I could insert the stuff about server side and client side. What you want to do is learn about the user's screen width. First of all, this is a bad idea if I you want to use it for design purposes like in this case where you include different CSS files. If I have a 1600x1200 screen, I can easily open a browser window at 640x480. And now? And even if you don't evaluate the screen width but the browser window's width: What about me resizing the already rendered page? Think about better designing the page so you don't need to switch the CSS... OK, enough of evangelism. If you really want to do what you told there: Evaluate the JavaScript on your entry page. Then do a redirect to that same page and insert the value into the URL (e.g. index.php?scrwidth=1280). You can then access this from PHP via $_GET. It is a good idea to store this value in the session once received so you don't have to send it around on each link. AllOLLi 63,000 bugs in the code, 63,000 bugs, ya get 1 whacked with a service pack, now there's 63,005 bugs in the code!! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Poll: PHP 4 / 5
Rasmus Lerdorf schrieb: [...] What do we do with code like this? If you follow it through it is essentially doing: 3 = banana; This is obviously totally wrong and has to be noted as wrong, hence E_NOTICE. Since it can be dealt with without rendering the script unexecutable raising a fatal error in PHP5 is wrong = switch that to E_NOTICE, too. But the problem for a lot of people using PHP applications simply is that they had perfectly running code and they weren't getting any notices at all. Now they still have working code but this one error in code they haven't written is throwing notices at them like hell. The quick answer is deactivate error reporting for production systems, but this is not a real solution for the PHP 4.x platform. People _using_ foreign code expect to get consistent behaviour from their applications. So the report level for this should be configurable for the 4.x branch with silence as default. AllOLLi The good news is: The whiskey works. [Lost in Translation] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] adding string...
John Nichel schrieb: Is there any difference in performance in these two ways? [...] The latter is less for you to type. ;) I had a prepared a similar answer but then I figured the question was explicitly focused on performance and dropped that note. But now I see that the question could be about code editing performance ;-) AllOLLi Do you want fries with that project? [CookieButton site info] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/mysql object id question..
Jasper Bryant-Greene schrieb: Oliver Grätz wrote: 3. Yes. One can abuse exceptions to return something in a constructor. Just another argument against exceptions ;-) OK, it's unorthodox, if you absolutely need to do that, do it and tell nobody *g*. This is not abusing exceptions. If you throw an exception then the expected behaviour should be that the following code should not be executed [1]. If you throw the exception for error purpose it's OK, but if you throw the exception just for the purpose of returning a value then it's abuse. That's what I meant. Throwing an exception inside a constructor will prevent the object from being created. It will not allow you to return something of your choice -- I haven't tested but I would expect that the variable you were setting as the object would either remain unset or would be set to NULL. Tested. non-object. At least this is as expected ;-) I'm not too sure why you said just another argument against exceptions (apart from perhaps a lack of understanding) as exceptions are a very useful feature in any language. Sorry I didn't mark this as personal opinion (just like all the rest). Exceptions make good programming more difficult without need. Raymond Chen wrote this about exceptions: http://blogs.msdn.com/oldnewthing/archive/2005/1/14.aspx AllOLLi This time it will surely run. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PDO for PHP 4 (was Re: Quick Poll: PHP 4 / 5)
Manuel Lemos schrieb: NEWSFLASH: PDO already exists for PHP 4: http://www.phpclasses.org/pdo One can't implement overloading of the Zend Engine 2 in PHP4 so this is not the full package. And then, the most important feature of PDO is that it's NOT WRITTEN IN PHP like any other database abstraction layer. It's written in C for speed. Despite of that, I do not think PDO is a compelling reason to use PHP 5. Basically it is yet another attempt to do the same where other abstraction layers extensions have failed like ODBC and DBX. It will not fail because it will be the de-facto-standard for new programmers. PHP tutorials will start containing PDO examples instead of mysql_* examples. That's even more true because the mysql extension is not included by default anymore. The matter is that PDO does not offer real database independence, so application developers that want to not have to deal with the important aspects that are different among databases will still have to deal them in their applications making their applications non-portable. This is true for the 10 percent of PHP programmers doing complicated database stuff. PDO still is good for them because PDO explicitly makes stuff unique to a particular DBMS available through its interface (the doc is full of this will only work for some engines). The other 90 percent will be fine with what PDO has to offer. AllOLLi I'm bitter? Who's drunk and yelling at a dead woman? [Lisa, 6Fu 501] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Poll: PHP 4 / 5
Manuel Lemos schrieb: A reference where _I_ have to search is something like a non-answer... If you try searching the bug database for PHP 4 versus PHP 5 opened bug reports you will get your answer. Same sentence still applies. But OK: PHP4 has 518 open bugs, PHP5 only 203. What does this say about the stability of PHP4? http://bugs.php.net/bugstats.php?phpver=4 http://bugs.php.net/bugstats.php?phpver=5 Also, PHP4 (first beta 19-Jul-1999) has a history of over 25300 bugs in its 6 year long history whereas PHP5 (first beta 29-Jun-2003) has had less than 4300 bugs filed in 2 years. Project this to 6 years and you are at 13000 filed bugs, roughly half as many as for PHP4. The site also states that PHP5 bugs are handled more quickly: PHP5: 47/3 vs PHP4: 71/5 (days average/median lifetime). So, you send me a link supporting my arguments. Thank you. In case it was not clear for you, what I am saying is not the matter is PHP 4.x vs. PHP 5.x, but rather upgrading vs. not upgrading. [...] I've got PHP5 and 4 running on the same machine. I just do not get why you still run PHP 4 when you are so confident that PHP 5 is the right version to use. Didn't you give yourself the answer? I'm not using PHP5 (read: upgrading) for stuff that doesn't want it (meaning its debian package requires PHP4). For my own projects I use PHP5 and if I decide to use some packages meant to be used with PHP4 I have yet to encounter real problems that are PHP5-problems. First of all, in many cases code reuse still is a myth. I hate to say it but it's true. Then, a large potion of the PHP community hasn't even heard of PEAR. Then, people definitely start projects from scratch. If You don't know if you have any numbers to back the large portion of the PHP community claim. The proof is the sheer number of this is *THE* PHP application framework to use sites on the internet. Some people don't like reusing code, some evaluate those projects and decide against them. For my part, before reinventing the wheel I always spend some time serching through PEAR and the web but very often the available solutions don't fit my needs. I simply suppose other developers tend to act the same way. Anyway, as the developer of phpclasses.org, the largest PHP class repository, I can inform you that the site has accumulated near 270,000 subscriber since 1999, of which at least half of them are considered active as you may verify here: http://www.phpclasses.org/browse/statistics/statistics.html The site has 2,200 approved packages but only 71 are PHP 5 specific. That is a lot of people reusing a lot of public class libraries! Ah, that thing. The site that always gives me problems when I try to log in after absence. I had switched to reregistering for every access before Berlios came along (thanks for threatening to sue them) and now I use the Monster TGZs. AllOLLi \let\thepage\relax -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Poll: PHP 4 / 5
Pooly schrieb: [x] I use a layer above PHP which is independant of whether it's PHP4 or PHP 5, which is running Migration from 4.x to 5.0.3 was as simple as changing a DNS record :-) http://templeet.org/ A layer above PHP would mean this thing generates code specific to the underlying PHP version or features PHP-version-based code switching. I doubt that. It surely is a PHP application in itself and therefore subject to problems depending on the PHP version used underneath. AllOLLi Hostage: You son of a bitch. Soong: Actually mother was a chemist. [Enterprise 405] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: adding string...
Gustav Wiberg schrieb: Hi guys! Is there any difference in performance in these two ways? $sql = $sql . OR $sql .= No difference. Even if there was any difference it would be totally negligible. AllOLLi Byers: What proof do you have? Bond: I got this! Byers: You're on the phone, Jimmy! [Lone Gunmen 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: PHP combined with JAVA
If I read this correctly then your question is in no way JAVA-specific. You want to instantiate an object (which you suppose to be of large size and slow in instantiation) and save this object in the session during page requests. First of all, any data put in the session array will be serialized (read: converted into a string containing all the data in this object). This in itself is slow for large objects. A performance gain for large objects through using a session isn't likely. The second problem with this - and this is the point where JAVA kicks in - not all data in objects is serializable. The Java-API of PHP is just some kind of adapter to the Java system. If you serialize an adapter object then your adapter is saved but not the Java object it uses (because PHP has no control over it). Think of the Java API as some kind of socket connection where you only see the stuff on your side (the client side) and the JAVA object on the server side is not under your control but just used. What happens is: you save you adapter object and the script terminates. The JAVA VM notices that an object is no longer referenced and it is thrown away by the garbage collection. What could you do? Well, you could use it the other way round (Servlet uses PHP), because then you control the JAVA side. Or you still do it the way you do it now but write some clever JAVA code that keeps running and retains your objects. You give those objects a name known to both the PHP and JAVA side and this name can be serialized. You can then re-reference any object on the next page request by its name. AllOLLi Jayne spits a large glob of saliva on his blade, wipes it on his shirt, shining it. Could you NOT do that while we're ever! [Simon on firefly 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Poll: PHP 4 / 5
Manuel Lemos schrieb: In theory those are the only changes. In practice, besides the officially admitted changes, there are also the bugs that were not yet discovered or fixed. Examples? Links? More information on this? The fact is that on php.internals there are discussions to reduce the number of maintained development threads. In the not-so-far future they will reduce the manpower put into backporting bugfixes to the PHP4.x development branch since 5.x is the HEAD revision and everything is first fixed there. I think all old stuff is just as mature in PHP5 as you know it from PHP4 and if some errors are found they are likely to be fixed more quickly for the 5.x release. The new stuff (that wasn't there before 5.0) almost certainly has more bugs since it's younger but that's no argument since this isn't relevant for old projects. I think the change from 4 to 5 ist that slow because there are so many programmers with VisualBasic (or worse) background that don't see the benefits of OOP. Iterators and delegation via interceptors are cool !?!? You can do OOP since PHP 3. PHP 5 OOP improvements are nice but they will not make anybody richer. The OOP features of PHP3 were nothing more than some kind of crippled namespaces for functions. PHP4 improved on that but PHP5 was the version to bring real OOP features to the language. It's the first versions to feature destructors and the possibility to overload parts of the Zend Engine for iterators or array access. You couldn't do $adr=new DB_Adress(12); // loads the adress with ID 12 from DB $adr['street']='Market Street'; // change the property //... // end of script, save changes to DB ? before PHP5. [...] As a matter of fact I just read this interesting article named The Six Dumbest Ideas in Computer Security that demonstrates what I always knew that upgrading to the latest versions is often a bad idea. Read the point #6) Action is Better Than Inaction . http://www.ranum.com/security/computer_security/editorials/dumb/ Nice article. Read it myself a few days ago (wasn't the link featured on Slashdot? *g*). Delaying upgrades might be true for running systems. But there's nothing keeping you from running both PHP4 and PHP5 on the same machine for different projects. And if you start a project from scratch PHP5 is the way to go. AllOLLi I just found the last bug. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Poll: PHP 4 / 5
Manuel Lemos schrieb: In theory those are the only changes. In practice, besides the officially admitted changes, there are also the bugs that were not yet discovered or fixed. Examples? Links? More information on this? The fact is that on php.internals there are discussions to reduce the number of maintained development threads. In the not-so-far future they will reduce the manpower put into backporting bugfixes to the PHP4.x development branch since 5.x is the HEAD revision and everything is first fixed there. I think all old stuff is just as mature in PHP5 as you know it from PHP4 and if some errors are found they are likely to be fixed more quickly for the 5.x release. The new stuff (that wasn't there before 5.0) almost certainly has more bugs since it's younger but that's no argument since this isn't relevant for old projects. I think the change from 4 to 5 ist that slow because there are so many programmers with VisualBasic (or worse) background that don't see the benefits of OOP. Iterators and delegation via interceptors are cool !?!? You can do OOP since PHP 3. PHP 5 OOP improvements are nice but they will not make anybody richer. The OOP features of PHP3 were nothing more than some kind of crippled namespaces for functions. PHP4 improved on that but PHP5 was the version to bring real OOP features to the language. It's the first versions to feature destructors and the possibility to overload parts of the Zend Engine for iterators or array access. You couldn't do $adr=new DB_Adress(12); // loads the adress with ID 12 from DB $adr['street']='Market Street'; // change the property //... // end of script, save changes to DB ? before PHP5. [...] As a matter of fact I just read this interesting article named The Six Dumbest Ideas in Computer Security that demonstrates what I always knew that upgrading to the latest versions is often a bad idea. Read the point #6) Action is Better Than Inaction . http://www.ranum.com/security/computer_security/editorials/dumb/ Nice article. Read it myself a few days ago (wasn't the link featured on Slashdot? *g*). Delaying upgrades might be true for running systems. But there's nothing keeping you from running both PHP4 and PHP5 on the same machine for different projects. And if you start a project from scratch PHP5 is the way to go. AllOLLi I just found the last bug. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Poll: PHP 4 / 5
Manuel Lemos schrieb: In theory those are the only changes. In practice, besides the officially admitted changes, there are also the bugs that were not yet discovered or fixed. Examples? Links? More information on this? The fact is that on http://bugs.php.net/ A reference where _I_ have to search is something like a non-answer... php.internals there are discussions to reduce the number of maintained development threads. In the not-so-far future they will reduce the manpower put into backporting bugfixes to the PHP4.x development branch since 5.x is the HEAD revision and everything is first fixed there. I In theory yes, in practice no. As a matter of fact PHP 4.4 was introduced after PHP 5.0, although the new version, new bugs is the same. PHP 4.4.0 is dated 11-Jul-2005 and kind of a -break-stuff version (the reference notice). PHP 5.0.5 is a bit late here (05-Sep-2005) but it fixes about two times as many bugs AND inbetween there has been the RC1 of PHP 5.1. Speaking of releases it seems true that The 4.x branch is quicker but looking at php.internals one can see that the people there fix it in the HEAD revision and then complain about having to backport fixes to the other branches and they want to get rid of this by just backporting _serious_ fixes. think all old stuff is just as mature in PHP5 as you know it from PHP4 and if some errors are found they are likely to be fixed more quickly for the 5.x release. The new stuff (that wasn't there before 5.0) almost certainly has more bugs since it's younger but that's no argument since this isn't relevant for old projects. Right, that is why most people with old projects will not upgrade to PHP 5. I've got PHP5 and 4 running on the same machine. [OO bologna] That is not the point. The point is that you said that people using PHP 4 do not see the benefits of OOP, as if they cannot do OOP in PHP 4. No, I said that those people have a pre-PHP background that keeps them from seeing any use for OOP at all. The procedural programming paradigma is so clean and simple because it doesn't deal with larger concepts like abstract datatypes and their methods. One can quicker start doing stuff: some simple variable types, functions to manipulate them, that's it. On the other side, there's object orientation. The datatypes are alive, they can do things themselves. Then there are interfaces, contracts about using things so that you can use different datatypes in the same way. And so on and so on. All this are more complex concepts that a programmer only realizes with the right background. And a lot of the PHP programmers come from non-OOP languages or start programming in PHP with no background at all. Even (and this is not the main, but a subpoint) in the pre-PHP5 era PHP had some kind of OOP but was not evangelising its use. The reality is that even in PHP 3 you can use benefit of OOP features such as encapsulation and inheritance. PHP 5 adds more OOP features, some copied from Java and Visual Basic, but that does not mean developers must use PHP 5 to do OOP. That depends on how one defines OOP. Some people are satisfied with what PHP3 offered, other people say that even PHP5 is not featuring some of the most important features (like namespaces or proper overloading of method prototypes without manually parsing the parameter array). For me, destructors and delegation (or multiple inheritance) are important points for an object oriented language. On the opposite, I don't like exceptions because I hate the jumping around in the code. So everyone has different expectations of OOP. It is also curious that you mention Visual Basic as if you could not do OOP in Visual Basic either. Did you know that not only you can do OOP since a long time ago in Visual Basic, but also you can make object variable accesses be implicitly implemented with setter and getter functions like you can now in PHP 5? I just refer to VisualBasic because some of the most ugly code I have ever seen is Visual Basic code. I might as well have mentioned Perl. Perl features a complete OOP implementation but it's such an ugly thing that the ordinary Java programmer would simply commit suicide if forced to use it. [scratch vs reuse] In theory yes, in practice nobody starts projects from scratch. Usually you reuse class libraries that are proven and implement many basic function. Many of those class libraries were built for PHP 4, not for PHP 5. Some are complex and large. If you use them in PHP 5 with prior certification chances are that you may stumble in PHP 5 bugs and backwards incompatible changes that make such libraries not work properly. Then even your new projects may be affected. First of all, in many cases code reuse still is a myth. I hate to say it but it's true. Then, a large potion of the PHP community hasn't even heard of PEAR. Then, people definitely start projects from scratch. If they didn't, there would be no PHPUnit2, Creole or
[PHP] Re: Webservices and PHP - thanx!
http://de.php.net/soap Short to not there questions provoke short answers AllOLLi I let you borrow my eggs for a whole year! [Susan on DH 106] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Poll: PHP 4 / 5
Richard Lynch schrieb: [...] Some of my sites are on 5. Some are on 4. I can't tell a difference. That's what I am evangelising. People seem very concerned about backward compatibility issues that _almost_ never come up (hell, the problems of PHP 4.3.x - 4.4 are more serious than 4-5!). People who are privately setting up a new machine should just go for the 5. Small hosting companies should do just like you told: keep the old ones on 4, go for 5 with new machines. And then there are large hosting companies who just feature all flavors of PHP on the same machine, easily switchable via .htaccess on a per-directory-basis. AllOLLi It's redundant! It's redundant! [R. E. Dundant] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] php/mysql object id question..
bruce schrieb: but then, i'm starting to realize that there's probably a great deal of 'opensource' code that's in use that hasn't been thoroughly vetted. 1. Constructors cannot explicitly return anything because they always return the new object. 2. OpenSource project and the code in them: 2.1 Most of the projects are grown over time. Over a long time. Do you know that moment when you look at code you wrote two years ago and find it disgusting? 2.2 Large projects have large programmer communities and therefore programmers with varying expertise. 2.3 It's PHP. It' PHP! The language a gorilla could learn. 3. Yes. One can abuse exceptions to return something in a constructor. Just another argument against exceptions ;-) OK, it's unorthodox, if you absolutely need to do that, do it and tell nobody *g*. AllOLLi Eric: Hello. Nadia: Hi! Eric: I'm.. Eric.. Weiss.. 38.. single. [Alias 402] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Quick Poll: PHP 4 / 5
I've changed to PHP5 and not experienced any problems with old code. In fact, the differences and incompatibilities are very minor and most projects should work without any changes. PHP5 features the new Zend Engine 2. It's not yet really faster than the one in PHP4 but has large potential. Without going into further details: It's better, especially if one wants to go with objects and classes. PHP5 features SQLite. Of course you can install the PECL module and use SQLite with PHP4 but some features like the iterators aren't available in PHP4. As an example: $db=new SQLiteDatabase('mydb.db'); foreach ( $db-query('SELECT * FROM adresses WHERE city=Sin City') as $adress) { echo $adress['name']; } That's simpler than in any PHP4/MySQL implementation. SQLite stores the database in a single file, there's no need for a server (like with MySQL). This makes it ideal for small quick and dirty projects or machines with old CPU and s small amount of RAM. Furthermore, PHP5.1 will introduce PDO which unifies this database interface for all db systems. It's a native database abstraction layer. You see, even if you don't want to use the OOP features like classes, interfaces and iterators you can still benefit from them in the standard modules. AllOlli Coffee anyone? :-Q -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Poll: PHP 4 / 5
Always this stuff about breaking backward compatibility. People seem to think that the change from 4 to 5 means such a lot. In fact the changes from PHP4.0 to PHP4.4 are much more numerous. The backwarr incompatible changes between 4 and 5 fit on asingle page of screen: http://de.php.net/manual/en/migration5.incompatible.php And most of these changes don't affect the normal programmer. I think the change from 4 to 5 ist that slow because there are so many programmers with VisualBasic (or worse) background that don't see the benefits of OOP. Iterators and delegation via interceptors are cool concepts but to use them you have to learn how to use them. And before you learn how to use them you have to understand what they're for and why they're cool. And before that you have to know that such things even exist. And with questions like How do I increment by more than one in a for loop on the forum this isn't very likely to be the case for a majority of the PHP community. It's a very big community with some experts and a lot of total beginners. And a beginner likes to stick with what works for him. I guess we'll have to wait for the hosters to adopt PHP5 and then for the next generation of PHP beginners. They will not know that there was PHP4 when they begin to learn. For example, they will use PDO for database access right from the start and intuitively use the iterator of PDOStatement. AllOLLi When you can't fix the problem, point it out and pretend it was intentional. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Quick Poll: PHP 4 / 5
Ben schrieb: [...] Hosting providers, which account for the vast majority of hosted domains, are pretty conservative. In Germany they're no that conservative. One of the biggest hosters in Germany (several million domains) allows to chosse between PHP 3, 4.0.6 4.3.x and 5.x via .htaccess Personally, SimpleXML was all I needed to switch after a particularly frustrating bought with php4 and xml parsing. SimpleXML is a good point. How could I forget it didn't exits with PHP4? AllOLLi Space: It seems to go on and on forever... [Futurama 101] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help: Get the value of pi up to 200+ digits?
Wong HoWang schrieb: but my server configure don't have bcmath enabled, is there any other way to do so? Since the internal routines of PHP have limited precision, you these options: - Find a way to activate bcmath (not likely to happen on a shared hosting account) - Find an external program that you can install and use (if you have shared hosting an ssh, you can probably install a command line version of bcmath) - find a web service (http://de.php.net/soap) that solves the problem (perhaps kind of overkill) - DIY (do it yourself). Implement an arbitrary precision PI algorithm in PHP (or perhaps somebody has already done this). AllOLLi It's just sex, it's totally harmless. [Gabrielle on DH109] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Computers name?
Gustav Wiberg schrieb: Hi there! Is it possible to get (retrieve) the computername of the client? I just want the name for comparing... In PHP all you get from the client is in the predefines variables: http://de.php.net/manual/en/language.variables.predefined.php Perhaps these are of any help: http://de.php.net/manual/en/reserved.variables.php#reserved.variables.server If you cannnot find what you need in these (hint: print_r($GLOBALS);), your last resort might be JavaScript which runs in a sandbox, too, so don't bet on it. AllOlli Byers: What proof do you have? Bond: I got this! Byers: You're on the phone, Jimmy! [Lone Gunmen 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Computers name?
Gustav Wiberg schrieb: Hi there! Is it possible to get (retrieve) the computername of the client? I just want the name for comparing... In PHP all you get from the client is in the predefines variables: http://de.php.net/manual/en/language.variables.predefined.php Perhaps these are of any help: http://de.php.net/manual/en/reserved.variables.php#reserved.variables.server If you cannnot find what you need in these (hint: print_r($GLOBALS);), your last resort might be JavaScript which runs in a sandbox, too, so don't bet on it. AllOlli Byers: What proof do you have? Bond: I got this! Byers: You're on the phone, Jimmy! [Lone Gunmen 09] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: htpasswd-style password generation w/PHP
http://www.thewebmasters.net/php/class.Htpasswd.phps Google htpasswd php, first hit. Don't people use search engines any more? AllOLLi Mal: How drunk was I last night? Jayne: I don't know. I passed out. [firefly 06] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: htpasswd-style password generation w/PHP
http://www.thewebmasters.net/php/class.Htpasswd.phps Google htpasswd php, first hit. Don't people use search engines any more? AllOLLi Mal: How drunk was I last night? Jayne: I don't know. I passed out. [firefly 06] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: (Yet another) I'm blind ... post
On a totally unrelated note: My god, is that ugly code! If I see this right there's only a single piece of real PHP in it: putting the variable in the action field. For the rest: Leave PHP an use pure HTML. Or use a decent form toolkit. like PEAR's HTML_Quickform. There's no point in tons of print-commands just putting out hardcoded strings. AllOlli -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] String format problem
Please keep in mind you are speaking about microseconds of performance improvements. Optimising on this level is complete and utter nonsense. Using output buffering may give your application a much higher performance boost. And then you can still use a cache (opcode cache, page cache, ...) which greatly enhances the performance. AllOlli References: - Buffering: http://php.net/ob_start - Caching for starters: http://derickrethans.nl/files/perf-hungary.pdf -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php