Re: [PHP] Re: use strict or similar in PHP?
Stuart wrote: 2009/3/1 Shawn McKenzie nos...@mckenzies.net Stuart wrote: 2009/2/28 Shawn McKenzie nos...@mckenzies.net Robert Cummings wrote: On Sat, 2009-02-28 at 00:11 +, Ashley Sheridan wrote: On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote: On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ASCII is only a subset of binary in a pedantic, literal sense. When people say binary file, they mean one that contains characters which are outside the normal display spectrum, such as chr(0), etc. And the argument that PHP is not compiled requires a certain level of pedantry and it is still an incorrect argument since it most certainly is compiled to an intermediary virtual machine code. Cheers, Rob. Still, in PHP $compile_time == $run_time. I haven't been following this thread, but this caught my eye as being completely wrong. There are distinct compile and execution phases when PHP runs a script, and different rules apply to each. If you don't believe me try defaulting the value of a class variable to the result of a function. -Stuart Rob, I wasn't talking about time. I was talking about they're pretty much the same as in when they execute. Stuart, Great, then show the OP how he can enforce strict error checking at compile time and halt compilation and runtime altogether. Like I said I haven't been following this thread so have no idea what the original question was. I was just pointing out that your assertion that $compile_time == $run_time is incorrect. As far as error checking goes the PHP engine performs syntactical checks during compile time but due to the highly flexible nature of the language it's not possible to do most error checking until runtime. -Stuart And I quote: Hello, I am beginner with PHP and prior to PHP I have worked with java for some time and with perl for very short period. I can't help to notice some things that are little annoyance for me with PHP, but I am sure someone more experienced can help me :-) Is there in PHP something like use strict from perl? I find it pretty annoying to need to run script over and over again just to find out that I made typo in variable name. Is there some way for PHP to cache some data on the page? I like very much PHP's speed but it would be even better to be able to cache some frequently used data from database? Also regarding databases, I liked a lot java's way of sending data to database using parameters (select * from user where username = ? and then passing parameter separately with database doing necessary escaping and everything). Is there something like PHPDBC similar to JDBC? TIA, Hans End Quote; Jim Lucas -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Sat, 2009-02-28 at 18:57 -0600, Shawn McKenzie wrote: Stuart wrote: 2009/2/28 Shawn McKenzie nos...@mckenzies.net Robert Cummings wrote: On Sat, 2009-02-28 at 00:11 +, Ashley Sheridan wrote: On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote: On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ASCII is only a subset of binary in a pedantic, literal sense. When people say binary file, they mean one that contains characters which are outside the normal display spectrum, such as chr(0), etc. And the argument that PHP is not compiled requires a certain level of pedantry and it is still an incorrect argument since it most certainly is compiled to an intermediary virtual machine code. Cheers, Rob. Still, in PHP $compile_time == $run_time. I haven't been following this thread, but this caught my eye as being completely wrong. There are distinct compile and execution phases when PHP runs a script, and different rules apply to each. If you don't believe me try defaulting the value of a class variable to the result of a function. -Stuart Rob, I wasn't talking about time. I was talking about they're pretty much the same as in when they execute. They're not if you're using a compile cache. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
The OP asked: Is there in PHP something like use strict from perl? I find it pretty annoying to need to run script over and over again just to find out that I made typo in variable name. And I've been waiting for an answer myself, but I haven't seen one. From what I remember, in perl if you use use strict; it requires to to define your variables (my) before using them. If you make a variable typo in your code, then you'll trigger an error when you try to run it. From what I've seen of php, even with using strict error reporting, you can do that all day long without generating an error. So the answer appears to be No, you can't do that in PHP. Is that the answer? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Sun, 2009-03-01 at 08:36 -0500, tedd wrote: The OP asked: Is there in PHP something like use strict from perl? I find it pretty annoying to need to run script over and over again just to find out that I made typo in variable name. And I've been waiting for an answer myself, but I haven't seen one. From what I remember, in perl if you use use strict; it requires to to define your variables (my) before using them. If you make a variable typo in your code, then you'll trigger an error when you try to run it. From what I've seen of php, even with using strict error reporting, you can do that all day long without generating an error. So the answer appears to be No, you can't do that in PHP. Is that the answer? You can do anything you want... :) ?php class StrictProps { private $___init = true; function StrictProps( $props ) { $propsList = func_get_args(); foreach( $propsList as $props ) { if( is_array( $props ) ) { foreach( $props as $prop = $init ) { $this-{$prop} = $init; } } else { $this-{$props} = null; } } $this-___init = false; } function __set( $name, $value ) { if( !$this-___init ) { die( 'Attempt to set non-existent property: ' .get_class( $this ).'-'.$name.\n ); } $this-{$name} = $value; } function __get( $name ) { die( 'Attempt to get non-existent property: ' .get_class( $this ).'-'.$name.\n ); } } // // Declare strict properties... // $my = new StrictProps( 'foo', 'fee', 'fii' ); print_r( $my ); // // Declare and intialize strict properties... // $my = new StrictProps( array( 'foo' = 'Foo1', 'fee' = 'Fee1' ) ); print_r( $my ); echo $my-foo.\n; echo $my-fee.\n; echo $my-blah.\n; ? Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
At 9:21 AM -0500 3/1/09, Robert Cummings wrote: On Sun, 2009-03-01 at 08:36 -0500, tedd wrote: The OP asked: Is there in PHP something like use strict from perl? I find it pretty annoying to need to run script over and over again just to find out that I made typo in variable name. And I've been waiting for an answer myself, but I haven't seen one. From what I remember, in perl if you use use strict; it requires to to define your variables (my) before using them. If you make a variable typo in your code, then you'll trigger an error when you try to run it. From what I've seen of php, even with using strict error reporting, you can do that all day long without generating an error. So the answer appears to be No, you can't do that in PHP. Is that the answer? You can do anything you want... :) Rob: Just to show that your words of wisdom don't go unnoticed, see here: http://php1.net/oop/strict/ That's pretty slick. Now if I only understood WT* you did, I would be a better programmer for it. Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Sun, 2009-03-01 at 09:48 -0500, tedd wrote: At 9:21 AM -0500 3/1/09, Robert Cummings wrote: On Sun, 2009-03-01 at 08:36 -0500, tedd wrote: The OP asked: Is there in PHP something like use strict from perl? I find it pretty annoying to need to run script over and over again just to find out that I made typo in variable name. And I've been waiting for an answer myself, but I haven't seen one. From what I remember, in perl if you use use strict; it requires to to define your variables (my) before using them. If you make a variable typo in your code, then you'll trigger an error when you try to run it. From what I've seen of php, even with using strict error reporting, you can do that all day long without generating an error. So the answer appears to be No, you can't do that in PHP. Is that the answer? You can do anything you want... :) Rob: Just to show that your words of wisdom don't go unnoticed, see here: http://php1.net/oop/strict/ That's pretty slick. Now if I only understood WT* you did, I would be a better programmer for it. I used the magic methods __set() and __get() to facilitate error handling. These methods fire when a property is not accessible. So when the property does not exist these will fire. So first we init the properties when we create an instance (I'll discuss this shortly)... to init them we are setting them, this fires the __set() method... but since we check the value of the private ___init property, we don't fire an error in this instance. Future requests for the properties will not incurr a hit to __set() or __get() as long as the property is defined. If it is not defined then voila, the error fires and we die (we could do anything such as fire an exception but I just die for the example). With respect to initialization I use func_get_args() so that an arbitrary number of parameters can be passed to the constructor. This is useful since we don't know the number of properties. I also check if an argument is an array. If it is an array then I treat it as a property with an initialized value and create and set the property accordingly. That's all there is to it. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Sun, 2009-03-01 at 09:57 -0500, Robert Cummings wrote: On Sun, 2009-03-01 at 09:48 -0500, tedd wrote: At 9:21 AM -0500 3/1/09, Robert Cummings wrote: On Sun, 2009-03-01 at 08:36 -0500, tedd wrote: The OP asked: Is there in PHP something like use strict from perl? I find it pretty annoying to need to run script over and over again just to find out that I made typo in variable name. And I've been waiting for an answer myself, but I haven't seen one. From what I remember, in perl if you use use strict; it requires to to define your variables (my) before using them. If you make a variable typo in your code, then you'll trigger an error when you try to run it. From what I've seen of php, even with using strict error reporting, you can do that all day long without generating an error. So the answer appears to be No, you can't do that in PHP. Is that the answer? You can do anything you want... :) Rob: Just to show that your words of wisdom don't go unnoticed, see here: http://php1.net/oop/strict/ That's pretty slick. Now if I only understood WT* you did, I would be a better programmer for it. I used the magic methods __set() and __get() to facilitate error handling. These methods fire when a property is not accessible. So when the property does not exist these will fire. So first we init the properties when we create an instance (I'll discuss this shortly)... to init them we are setting them, this fires the __set() method... but since we check the value of the private ___init property, we don't fire an error in this instance. Future requests for the properties will not incurr a hit to __set() or __get() as long as the property is defined. If it is not defined then voila, the error fires and we die (we could do anything such as fire an exception but I just die for the example). With respect to initialization I use func_get_args() so that an arbitrary number of parameters can be passed to the constructor. This is useful since we don't know the number of properties. I also check if an argument is an array. If it is an array then I treat it as a property with an initialized value and create and set the property accordingly. That's all there is to it. Oh, I didn't bother, but if someone finds this at all useful, they could use debug_backtrace() to walk the call stack and output the actual source file and line number where the illegal property was requested. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Sat, 2009-02-28 at 00:11 +, Ashley Sheridan wrote: On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote: On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ASCII is only a subset of binary in a pedantic, literal sense. When people say binary file, they mean one that contains characters which are outside the normal display spectrum, such as chr(0), etc. And the argument that PHP is not compiled requires a certain level of pedantry and it is still an incorrect argument since it most certainly is compiled to an intermediary virtual machine code. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
Robert Cummings wrote: On Sat, 2009-02-28 at 00:11 +, Ashley Sheridan wrote: On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote: On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ASCII is only a subset of binary in a pedantic, literal sense. When people say binary file, they mean one that contains characters which are outside the normal display spectrum, such as chr(0), etc. And the argument that PHP is not compiled requires a certain level of pedantry and it is still an incorrect argument since it most certainly is compiled to an intermediary virtual machine code. Cheers, Rob. Still, in PHP $compile_time == $run_time. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Sat, 2009-02-28 at 09:04 -0600, Shawn McKenzie wrote: Robert Cummings wrote: On Sat, 2009-02-28 at 00:11 +, Ashley Sheridan wrote: On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote: On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ASCII is only a subset of binary in a pedantic, literal sense. When people say binary file, they mean one that contains characters which are outside the normal display spectrum, such as chr(0), etc. And the argument that PHP is not compiled requires a certain level of pedantry and it is still an incorrect argument since it most certainly is compiled to an intermediary virtual machine code. Cheers, Rob. Still, in PHP $compile_time == $run_time. No, compile time is usually a fraction of run time. And with a bytecode cache like eAccelerator or APC then it's not even considerable. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
2009/2/28 Shawn McKenzie nos...@mckenzies.net Robert Cummings wrote: On Sat, 2009-02-28 at 00:11 +, Ashley Sheridan wrote: On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote: On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ASCII is only a subset of binary in a pedantic, literal sense. When people say binary file, they mean one that contains characters which are outside the normal display spectrum, such as chr(0), etc. And the argument that PHP is not compiled requires a certain level of pedantry and it is still an incorrect argument since it most certainly is compiled to an intermediary virtual machine code. Cheers, Rob. Still, in PHP $compile_time == $run_time. I haven't been following this thread, but this caught my eye as being completely wrong. There are distinct compile and execution phases when PHP runs a script, and different rules apply to each. If you don't believe me try defaulting the value of a class variable to the result of a function. -Stuart -- http://stut.net/
Re: [PHP] Re: use strict or similar in PHP?
Stuart wrote: 2009/2/28 Shawn McKenzie nos...@mckenzies.net Robert Cummings wrote: On Sat, 2009-02-28 at 00:11 +, Ashley Sheridan wrote: On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote: On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ASCII is only a subset of binary in a pedantic, literal sense. When people say binary file, they mean one that contains characters which are outside the normal display spectrum, such as chr(0), etc. And the argument that PHP is not compiled requires a certain level of pedantry and it is still an incorrect argument since it most certainly is compiled to an intermediary virtual machine code. Cheers, Rob. Still, in PHP $compile_time == $run_time. I haven't been following this thread, but this caught my eye as being completely wrong. There are distinct compile and execution phases when PHP runs a script, and different rules apply to each. If you don't believe me try defaulting the value of a class variable to the result of a function. -Stuart Rob, I wasn't talking about time. I was talking about they're pretty much the same as in when they execute. Stuart, Great, then show the OP how he can enforce strict error checking at compile time and halt compilation and runtime altogether. -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
2009/3/1 Shawn McKenzie nos...@mckenzies.net Stuart wrote: 2009/2/28 Shawn McKenzie nos...@mckenzies.net Robert Cummings wrote: On Sat, 2009-02-28 at 00:11 +, Ashley Sheridan wrote: On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote: On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ASCII is only a subset of binary in a pedantic, literal sense. When people say binary file, they mean one that contains characters which are outside the normal display spectrum, such as chr(0), etc. And the argument that PHP is not compiled requires a certain level of pedantry and it is still an incorrect argument since it most certainly is compiled to an intermediary virtual machine code. Cheers, Rob. Still, in PHP $compile_time == $run_time. I haven't been following this thread, but this caught my eye as being completely wrong. There are distinct compile and execution phases when PHP runs a script, and different rules apply to each. If you don't believe me try defaulting the value of a class variable to the result of a function. -Stuart Rob, I wasn't talking about time. I was talking about they're pretty much the same as in when they execute. Stuart, Great, then show the OP how he can enforce strict error checking at compile time and halt compilation and runtime altogether. Like I said I haven't been following this thread so have no idea what the original question was. I was just pointing out that your assertion that $compile_time == $run_time is incorrect. As far as error checking goes the PHP engine performs syntactical checks during compile time but due to the highly flexible nature of the language it's not possible to do most error checking until runtime. -Stuart -- http://stut.net/
Re: [PHP] Re: use strict or similar in PHP?
Stuart wrote: 2009/3/1 Shawn McKenzie nos...@mckenzies.net Stuart wrote: 2009/2/28 Shawn McKenzie nos...@mckenzies.net Robert Cummings wrote: On Sat, 2009-02-28 at 00:11 +, Ashley Sheridan wrote: On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote: On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ASCII is only a subset of binary in a pedantic, literal sense. When people say binary file, they mean one that contains characters which are outside the normal display spectrum, such as chr(0), etc. And the argument that PHP is not compiled requires a certain level of pedantry and it is still an incorrect argument since it most certainly is compiled to an intermediary virtual machine code. Cheers, Rob. Still, in PHP $compile_time == $run_time. I haven't been following this thread, but this caught my eye as being completely wrong. There are distinct compile and execution phases when PHP runs a script, and different rules apply to each. If you don't believe me try defaulting the value of a class variable to the result of a function. -Stuart Rob, I wasn't talking about time. I was talking about they're pretty much the same as in when they execute. Stuart, Great, then show the OP how he can enforce strict error checking at compile time and halt compilation and runtime altogether. Like I said I haven't been following this thread so have no idea what the original question was. I was just pointing out that your assertion that $compile_time == $run_time is incorrect. As far as error checking goes the PHP engine performs syntactical checks during compile time but due to the highly flexible nature of the language it's not possible to do most error checking until runtime. -Stuart Unfortuantely, my post was in reference to the OP's question and related to other posts in the thread. :-) -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
Stuart wrote: As far as error checking goes the PHP engine performs syntactical checks during compile time but due to the highly flexible nature of the language it's not possible to do most error checking until runtime. I don't know (or care) how to do it but I suspect that if you put all output into a buffer or object (ala DOMDocument class) you could refuse to print the document to the requesting client if any errors were thrown during the creation of the document. DOMDocument sure makes (at least for me) code easier to read because you aren't mixing html and php. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: use strict or similar in PHP?
Hans Schultz wrote: Is there in PHP something like use strict from perl? I find it pretty annoying to need to run script over and over again just to find out that I made typo in variable name. I find that my IDE catches most of the typos before I even try to run the page. I use Netbeans 6.5 with the PHP extension, but there are alternatives... Is there some way for PHP to cache some data on the page? I like very much PHP's speed but it would be even better to be able to cache some frequently used data from database? Generally it's not worth the trouble, but you could cache in the session... Remember that PHP is largely stateless, so one page call knows nothing of any other page calls. This is different to Java, where you can hold state in the underlying virtual machine and recover it later... Also regarding databases, I liked a lot java's way of sending data to database using parameters (select * from user where username = ? and then passing parameter separately with database doing necessary escaping and everything). Is there something like PHPDBC similar to JDBC? With PostgreSQL (and probably MySQL too) you can do either a prepared statement (see http://www.php.net/manual/en/function.pg-prepare.php) and then execute that, or a simpler parameterised query (see http://www.php.net/manual/en/function.pg-query-params.php) Something like $sql = 'SELECT * FROM user WHERE username=$1'; $params = Array('pete'); $result = pg_query_params($sql,$params); That way you get the safest handling of values without any tedious messing about with manually escaping strings. I suspect that under the hood it actually prepares a statement and then executes it, but I might be wrong... -- Peter Ford phone: 01580 89 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: use strict or similar in PHP?
Thanks, this is the most useful answer I got. I will try to use that IDE and to see if it works for me. Regarding databases I was hopping for some abstraction layer like dbx only better (to allow parameters). Regards, Hans On Fri, 27 Feb 2009 15:41:55 +0100, Peter Ford p...@justcroft.com wrote: Hans Schultz wrote: Is there in PHP something like use strict from perl? I find it pretty annoying to need to run script over and over again just to find out that I made typo in variable name. I find that my IDE catches most of the typos before I even try to run the page. I use Netbeans 6.5 with the PHP extension, but there are alternatives... Is there some way for PHP to cache some data on the page? I like very much PHP's speed but it would be even better to be able to cache some frequently used data from database? Generally it's not worth the trouble, but you could cache in the session... Remember that PHP is largely stateless, so one page call knows nothing of any other page calls. This is different to Java, where you can hold state in the underlying virtual machine and recover it later... Also regarding databases, I liked a lot java's way of sending data to database using parameters (select * from user where username = ? and then passing parameter separately with database doing necessary escaping and everything). Is there something like PHPDBC similar to JDBC? With PostgreSQL (and probably MySQL too) you can do either a prepared statement (see http://www.php.net/manual/en/function.pg-prepare.php) and then execute that, or a simpler parameterised query (see http://www.php.net/manual/en/function.pg-query-params.php) Something like $sql = 'SELECT * FROM user WHERE username=$1'; $params = Array('pete'); $result = pg_query_params($sql,$params); That way you get the safest handling of values without any tedious messing about with manually escaping strings. I suspect that under the hood it actually prepares a statement and then executes it, but I might be wrong... -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: use strict or similar in PHP?
On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
--- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
Robert Cummings wrote: ... the line between the definition of interpreted language and compiled language is quite blurry these days. #includestdio.h main() { printf(Hello World); } Compile that - and you can run it on any system that is binary compatible, whether or not is has a C compiler. However, it will not run on systems that are not binary compatible, even if they have a C compiler. ?php print (Hello World); ? That will only run on systems with a php interpreter, even if you compile it into byte-code. However, unlike the c example, it will run on any system with a php interpreter. Nothing fuzzy about it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Fri, 2009-02-27 at 14:32 -0800, Michael A. Peters wrote: Robert Cummings wrote: ... the line between the definition of interpreted language and compiled language is quite blurry these days. #includestdio.h main() { printf(Hello World); } Compile that - and you can run it on any system that is binary compatible, whether or not is has a C compiler. However, it will not run on systems that are not binary compatible, even if they have a C compiler. ?php print (Hello World); ? That will only run on systems with a php interpreter, even if you compile it into byte-code. However, unlike the c example, it will run on any system with a php interpreter. Nothing fuzzy about it. This is not the litmus test for compiled versus interpreted languages. http://en.wikipedia.org/wiki/Compiled_language Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Friday 27 February 2009 10:56, Hans Schultz wrote: Regarding databases I was hopping for some abstraction layer like dbx only better (to allow parameters). I encourage you to use a database abstraction layer that gives you this and many other features you may be used to from JDBC MDB2 and PDO are the most current and popular http://pear.php.net/manual/en/package.database.mdb2.intro-execute.php http://us.php.net/manual/en/pdo.prepared-statements.php enjoy, Sam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: use strict or similar in PHP?
On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote: On Sat, 2009-02-28 at 00:02 +0600, 9el wrote: --- Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get a Free CD of Ubuntu mailed to your door without any cost. Visit : www.ubuntu.com -- On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote: On Feb 27, 2009, at 6:12, Hans Schultz h.schult...@yahoo.com wrote: Hahahah,I was thinking the same thing The trouble is most people mean compile a source file to an executable binary when they sat compile. By this measure, PHP does not compile. I add the following to the top of my PHP shell scripts: #!/usr/bin/php -qC Then I do the following: chmod 775 script.php Then I run it as follows: ./script.php Look... and executable binary :) Don't say it's not binary. All data on a hard disk is binary (although I do know what you mean ;) Well you are running shell script style execution its not example of Compiled code or Binary The data in the file is ASCII or UTF text :) Which are subsets of binary representation ;) Compilation happens when its zendOptimized or OpCoded. Its then is converted into binary content file. But one could probably quite easily set up a system whereby eAccelerator or APC or Zend Optimizer cache bytecodes are torn from a file run similarly. As I said in an earlier post... the line between the definition of interpreted language and compiled language is quite blurry these days. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP ASCII is only a subset of binary in a pedantic, literal sense. When people say binary file, they mean one that contains characters which are outside the normal display spectrum, such as chr(0), etc. Ash www.ashleysheridan.co.uk -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php