Re: [PHP] ioctl() in PHP

2002-12-09 Thread Filippo Veneri
On Mon, 2002-12-09 at 13:41, Lokesh Setia wrote:
> 
> 
> Hello PHP'ers!
> 
> We wish to control a hardware device (a GPIB card) using a web
> interface.  This device is normally controlled using either:
> 
> 1. simple ioctl() calls to the linux kernel
> 2. by a higher level C-library which inturn calls these ioctl()s.
> 
> Does PHP support system calls like ioctl()? I was unable to find it in
> the PHP manual.  Or even better, can I use the high-level C library
> functions for this card from within PHP, without _too_ much of hacking
> into the internals of PHP ?
> 
I'm not an expert, but I think that your best bet is to write an
external module for php that creates the necessary bindings for your
high level API.
Check the docs for the details:
http://www.php.net/manual/en/zend.php

bye,

fbv


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




[PHP] variable scope in nested functions

2002-12-09 Thread Filippo Veneri
Is there a way to access a variable defined in a function from a nested
function, without putting the variable in the global scope?
Perhaps some code will make my question clearer:

function enclosing() {
$variable1;
function enclosed() {
can I access $variable1 from here?
}
}

Thanks,

fbv


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




[PHP] assignment to $this inside constructor

2002-12-04 Thread Filippo Veneri
Let's begin with a small code snippet:



class A {
function A( $selector ) {
switch( $selector ) {
case 1: $obj = new A_1(); break;
case 2: $obj = new A_2(); break;
...
}
$this = $obj;
}
}

class A_1 {
...
}

class A_2 {
...
}

$a = new A(1); // $a is now an instance of A_1
$a = new A(2); // $a is now an instance of A_2



I use this trick to implement "polymorphic" objects.
I just wanted to know what other people think about
it.
Is this a "dangerous" technique? (i.e. changes in php
object model can break programs that use it)
Is it already in common use?
Any opinion is welcome.

Thanks

fbv


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




[PHP] Re: object reflection in php?

2002-03-19 Thread Filippo Veneri

Thanks to all who posted!

What i was looking for is
object_get_vars(), which,
for some reason, is not
present in my (offline) copy
of the manual.

Thanks again,

fbv

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




[PHP] object reflection in php?

2002-03-18 Thread Filippo Veneri

Is there a way to get the name of a filed
from a variable pointing to some object?

Just to make myself understood:

class obj {
   var $field;
   function obj( $value ) {
 $this->field = $value;
   }
}

$o = new obj( "field value" );

How can i know, if possible,  that the instance of
obj pointed to by $o has a field named "field"?

This would be useful to write an object to a database
without knowing its structure 'a-priori'.

Thanks

fbv


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




[PHP] Re: uploading images

2002-03-09 Thread Filippo Veneri

George Whiffen wrote:

> Wierd, sounds like it could be a bug.  What's the actual code you use
> for the upload?
> 
> I presume you are running vim from the command line of the box to which
> the image is
> uploaded.  Content-Type: image/jpeg is, of course, what Apache would add
> if you requested a .jpg file over
> the web.
> 
> Good Luck,
> 
> George

The code i use is a trivial variant of that presented in PHP
documentation. The exact same code works fine on the debian
i386 machine, which runs apache 1.3.9 + PHP 4.0.3pl1.

The powerpc linux box is my developement machine, not the
deployment one, so this is not a terrible problem. I still have
the debian to develop on. Besides that, the upcoming update from
yellowdog linux should solve my problem on the ppc box as well.

Thanks,

fbv

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




[PHP] upload corrupts images

2002-03-07 Thread Filippo Veneri

When i upload an image file (i.e. a jpeg) to the server
using php, it gets corrupted. Indeed the GIMP is no
longer able to open it.
Opening the uploaded file with a text editor i found that
the following 2 lines were added at the top (as displayed by
vim, my text editor):

Content-Type: image/jpeg^M
^M

This happens on my yellowdog (a redhat 7.1
derived powerpc based distro) linux box, with version 4.0.4pl1
of php. On the other hand, on a i386 debian machine vith
php 4.0.3pl1 everything works fine.

Is this a known bug/issue?

Thasks,
fbv

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




[PHP] uploading images

2002-03-07 Thread Filippo Veneri

When uploading image files to my powerpc linux box (derived
from redhat 7.1) running apache + php4.0.4pl1 something
wierd happen.
Images get corrupted by (IMHO) php itself. It adds the
following 2 lines at the top of the file:

Content-Type: image/jpeg^M
^M
...(rergular image file data)

(as displayed by my text editor, vim).

It seems a bug, as uploading images to another machine
(a i386 debian 2.2 box) works as expected.

Is this a known issue/bug?

thanks,
fbv

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