[PHP] Re: creating objects by reference?

2002-12-18 Thread Matthew Gray
Jonathan Sharp wrote:

> Is it better to do:
> $obj = &new object();
> 
> verses:
> $obj = new object();
> 
> thanks,
> -js

If you are looking to the future: I don't believe the ability to return 
objects by reference will be an option in Zend Engine 2.

Matt


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: is there php equiv left() and right() functions?

2002-12-18 Thread Matthew Gray
Jeff Bluemel wrote:

> I have a string that will look like the following;
> 
> data1|data2
> 
> now - I need to put data1 in a variable, and data2 in another variable.
> I've found the functions strlen, and strpos, but I can't figure how to
> grab this data.
> 
> thanks,
> 
> Jeff

Try

list($var1, $var2) = explode('|', 'data1|data2');

Matt

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Convert a grayscale value to a #RRGGBB hex value

2002-06-24 Thread Matthew Gray

If you know its grayscale...

function GrayScaleToHex( $val ) {

$norm = $val * 2.55 + $val/100;
$hex = sprintf("%02X", $norm);
return '#' . $hex . $hex . $hex;
}

Should get you close enough.

Matt


René fournier wrote:

> Anyone know how I might convert a grayscale value, from between 0 to 
> 100, to hex, such that 0 (black) would be returned as #00, and 100 
> (white) as #FF? For example...
>
> function grayscaletohex ($val) {
> $hex = $val ... [ a simple operation ]
> return $hex;
> }
>
> Thanks.
>
> ...Rene
>
> ---
> René Fournier,
> [EMAIL PROTECTED]
>
> Toll-free +1.888.886.2754
> Tel +1.403.291.3601
> Fax +1.403.250.5228
> www.smartslitters.com
>
> SmartSlitters International
> #33, 1339 - 40th Ave NE
> Calgary AB  T2E 8N6
> Canada
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Classes Constructor syntax

2002-07-17 Thread Matthew Gray

PHP does not support multiple constructors. But, It does support 
variable argument lists, so you can fake it with func_get_args() and 
func_get_num_args():

function issue() {

if( func_get_num_args() > 0 ) {
   
$args = func_get_args()

} else {

 // do something else...
}
}

Matt

David Russell wrote:

> Hi all,
>
> I am finally spending some time converting a million and one functions 
> into a class - this is for a software issue tracking system.
>
> I have:
>
> class issue {
>   var
>   var
>   ...
>
>   function issue() { //default constructor
> //initialise all variables to defaults, and start getting the 
> stuff from forms
>   }
>
>   function issue($number) { //1 variable constructor
> // Query database and populate variables accordingly
>   }
> }
>
> My question is: will this work? does PHP OOP support more than one 
> constructor? If my syntax is wrong, please let me know the correct 
> syntax.
>
> Thanks
>
> David R
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] Re: Image functions

2002-04-19 Thread Matthew Gray

You won't get very far if you aren't outputting an image to the browser
using ImageJpeg(), etc.

Matt

Matthew J Gray
UWRF - Information Technology Services
[EMAIL PROTECTED]

Gerard Samuel wrote:

> Im trying to modify a poll script to not use the hard coded image files
> and use php's image functions.
> On the file that will be outputing the poll graphics, I tried at the top
> of the page ->
> header("Content-type: image/png");
> and
> header("Content-type: image/jpeg");
>
> For some reason, when the page is viewed, the only thing that gets
> output to the browser is the url of the page
>
> I tried using one of the examples on php.net image create routines and
> its still doing the same thing..
>
> Here is a snip
>
> 
> /*
>  *  THIS HAS TO GO HERE FOR THE IMAGE BARS
>  */
> header("Content-type: image/jpeg");
>
> $pollID = $HTTP_POST_VARS['pollID'];
> $voteID = $HTTP_POST_VARS['voteID'];
>
> <--snip->
>
> If I comment out the header call, Im back to normal...
> Im running PHP 4.1.2 with GD support
> Any thoughts
> Thanks


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php