Re: [PHP] PHP CLI setting cooked terminal mode

2013-09-11 Thread Alain Williams
On Wed, Sep 11, 2013 at 05:45:45PM +0100, Stuart Dallas wrote:
> On 11 Sep 2013, at 17:37, Alain Williams  wrote:

> Make sure output buffering is off by putting this at the top of your script:
> 
> while(ob_end_clean());

Sorry, that does not fix the problem - but thanks for trying.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



[PHP] PHP CLI setting cooked terminal mode

2013-09-11 Thread Alain Williams
Hi,

I am running a PHP script at the command line and piping the output through 
less:

./myScript | less

Since less is an interactive program it puts the terminal into 'raw' mode so
that it can read characters one at a time. However, when I do the above I find
that the commands that I type to less are echoed back to me and not acted on
until I type . This is not as it should be.

The sript is not doing anything really clever, just looking at a few files and
printing out directory contents, time stamps, ...

If I run the script under strace I see:

ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo 
...}) = 0
ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0


I can get it to not do this by connect stdout to /dev/null:

./myScript > /dev/null | less

another way of getting it to work is (and this shows that it really is PHP that
is messing the tty modes):

./myScript > /dev/null | (sleep 10;less)

However: PHP should not set the terminal to cooked mode in the first place

Is there any way in which I can get PHP to not do this ?

TIA

I am running PHP 5.3.3 on CentOS 6.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] Trying to understand what I've broken to not allow mkdir() to work.

2013-05-16 Thread Alain Williams
On Thu, May 16, 2013 at 03:33:53PM +0100, Richard Quadling wrote:
> Hi.
> 
> I'm running on a Mac with a Centos VM (via VirtualBox).
> 
> Was running from from our SVN server.
> 
> New repo, now running from GIT.
> 
> The checkout is on my local machine (using Netbeans, LESS, etc.)
> 
> The VM is running Apache and PHP V5.4.15
> 
> During the move, I've got some permissions issues, which I simply don't
> understand enough to a) resolve myself, b) know what to ask for to get the
> right help in solving the issue.
> 
> I've been told that the permissions on my mac via the shared folder through
> VirtualBox to the Centos setup is where my problem lies. But I don't know.
> 
> Is there anyone who can give me definite help here? I can manually create
> the directories, but that's just daft.
> 
> Nothing LOOKS any different between the two repos, but I don't know how to
> tell beyond comparing ls outputs.
> 
> Any help would be good.

Have you got SELinux switched on ? Try:

ls -lZ

getenforce

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] SPL Recursive Iterator Examples

2013-03-19 Thread Alain Williams
On Tue, Mar 19, 2013 at 04:40:59AM -0700, NaMarPi wrote:
> 
> 
> I have not found enough documents about Recursive Iterators on the net, so 
> started to collect my mini-examples here:
> 
> 
> https://github.com/namarpi/PHP-SPL-Recursive-Examples

If you are putting them up as examples, then it would be good if there were
plentiful comments that said what they were supposed to do, why, how ...

Regards

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] Customized Session Handler can not work for PHP 5.1.6 and CentOS 5.5

2012-04-15 Thread Alain Williams
On Sun, Apr 15, 2012 at 12:27:00AM +0800, Mingda wrote:
> Hi, All,
> 
> System: CentOS 5.5; PHP version is 5.1.6.
> 
> I met a strange problem associate with session_save_handler in current 
> environment(The same code can work well in my local windows platform and 
> ubuntu system).
> 
> I just want to use a customized session save handler to be triggered, so 
> that I can call my own logic to handling the session. The testing in 
> local is pretty great but when migration to the VPS, it bring me the 
> following error:
> 
> Fatal error: session_start() [ href='function.session-start'>function.session-start]: Failed to 
> initialize storage module: user (path: /tmp)
> 
> 
> The default value for session save handler and session save path in 
> php.ini are:
> 
> session.save_handler = files
> session.save_path = "/tmp"
> session.name = PHPSESSID

Try changing the path to /var/lib/php/session

Are you being caught by selinux - try
setenforce off
and see if that makes it work.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] Re: Long Live GOTO

2012-02-06 Thread Alain Williams
On Mon, Feb 06, 2012 at 09:28:10AM -0700, Larry Martell wrote:
> On Mon, Feb 6, 2012 at 9:23 AM, Alain Williams  wrote:

> > If I survey my code I find that I use one GOTO in about 4,000 lines of code 
> > -
> > that I do not find excessive.
> >
> > There are, however, people who consider any GOTO as communion with the 
> > devil.
> > IMHO: not so - if used sparingly.
> 
> Just for another data point, the FAA does not allow gotos in any code
> that goes into an airplane.

And your point is ?

It just means that someone in the FAA does not like GOTO.
If you can come up with their reasoned argument for the ban I will look at it,
but without that the data point does not have much value - IMHO.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] Re: Long Live GOTO

2012-02-06 Thread Alain Williams
On Mon, Feb 06, 2012 at 11:12:53AM -0500, Jim Giner wrote:
> NO "GO"!
> As one who started back in the 70's with old style coding that utilized GoTo 
> in Cobol, Fortran, etc. and had to deal with "spaghetti code" written by 
> even earlier developers who never considered that someone else would have to 
> maintain their code, I feel strongly that GoTo is not to be used.

I remember being faced with spaghetti code 35 odd years ago - yes, horrible.
But what do we mean by ''spaghetti code'' ? I remember code where every 3rd
statement was some form of GOTO - yuck!

One very desirable feature of code is that it be clear, ie: lucid, able to be
understood by others. Too many GOTO statements and it is hard.

However: a few GOTOs can make things clearer.  Think of a function that can fail
in several different places (eg data validation, ...).  But it is reading a file
which needs to be closed before the function returns.  I have seen code where
some $IsError variable is tested in many places to see if things should be done.
That is just as bad as lots of GOTO -- often when having to write something like
that I will have a GOTO (in several places) to the bottom of the function that
closes the file and returns failure.

That is much clearer than extra variables.

If I survey my code I find that I use one GOTO in about 4,000 lines of code -
that I do not find excessive.

There are, however, people who consider any GOTO as communion with the devil.
IMHO: not so - if used sparingly.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] Way to output HTML on professional websites

2011-12-27 Thread Alain Williams
On Mon, Dec 26, 2011 at 11:39:06PM -0500, Paul M Foster wrote:
> On Tue, Dec 27, 2011 at 12:46:29AM +0100, Florian Müller wrote:
> 
> > 
> > Hi guys
> > Just a little question: I've programmed some nice little websites up to 
> > 25'000 lines of code.
> > Now if I see some bigger websites just as facebook and so on, how are they 
> > printing their website out?
> > Does it work like 
> > ...";?>
> > or do they output it like
> > 
> > 
> > 
> > Or is the code even generated or gotten from a database and evaluated?
> > How does the website itself gets printet on really professional websites?
> > Thanks for answer!
> 
> You're asking for an opinion. In mine, if you have to call fifty files
> before printing a byte to screen, you've introduced too much complexity.
> I just finished up five weeks at a company where they were calling
> probably upwards of 100 files before printing anything on screen.

Have a look at smarty:

http://www.smarty.net/

I like it a lot ... helps with complicated web sites.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] PHP script won't run in the background

2011-11-30 Thread Alain Williams
On Wed, Nov 30, 2011 at 01:01:48PM +0100, richard gray wrote:

> >You need a bit more info, get a backtrace with 'where'.
> Thanks for the response Alain - below is the output:-

Ah, much more useful .

> [rich@LeMans] (/Web/scripts)> gdb --pid=3294
> GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug  8 20:32:45 
> UTC 2011)
> Copyright 2004 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain 
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for details.
> This GDB was configured as "x86_64-apple-darwin".
> /Web/scripts/3294: No such file or directory
> Attaching to process 3294.
> Reading symbols for shared libraries . done
> Reading symbols for shared libraries 
> 
>  
> done
> Reading symbols for shared libraries + done
> 0x7fff8f8ac7ee in __ioctl ()
> (gdb) where
> #0  0x7fff8f8ac7ee in __ioctl ()
> #1  0x7fff8f8ac1fe in ioctl ()
> #2  0x7fff910a6b1c in tcsetattr ()

OK - it is setting tty modes as I suspected.

> #3  0x00010ab05df7 in tty_end ()
> #4  0x00010ab05c39 in tty_init ()
> #5  0x00010aaf7261 in el_init ()
> #6  0x00010aafeb8e in rl_initialize ()
> #7  0x00010a3ef39a in zm_startup_readline ()

This is the readline routine ... probably setting the tty to raw mode, thus the 
tcsetattr() above.

Look at the link below, it is how your CLI version of PHP is compiled:

http://www.php.net/manual/en/readline.installation.php

readline is mentioned as part of CLI:

http://www.php.net/manual/en/features.commandline.usage.php

> #8  0x00010a37a1c8 in zend_startup_module_ex ()
> #9  0x00010a38166b in zend_hash_apply ()
> #10 0x00010a37d3dd in zend_startup_modules ()
> #11 0x00010a3287bf in php_module_startup ()
> #12 0x00010a3ef637 in php_cli_startup ()

This is done BEFORE your script starts - so nothing that you can do to stop it.

> #13 0x00010a3efff8 in main ()

Try the daemonize that I wrote about a few minutes ago.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] PHP script won't run in the background

2011-11-30 Thread Alain Williams
On Wed, Nov 30, 2011 at 12:58:26PM +0100, richard gray wrote:
> On 29/11/2011 17:16, Daniel Brown wrote:
> >On Sat, Nov 19, 2011 at 09:33, richard gray  wrote:
> >This happens because PHP is writing to STDOUT, of course, and then the 
> >command line redirection grabs that information and puts it into the 
> >file. Unfortunately, by itself, this won't work in the background, 
> >which is why you're getting the SIGTTOU (SIGnal TTy OUput). If you 
> >need to redirect the output and have it run in the background (where 
> >something like file_put_contents() or fwrite() isn't a practical 
> >option), give it a NOHUP (NO Hang-UP): nohup php test.php > test.log & 
> >This will automatically redirect STDERR to STDOUT, save for the 
> >message telling you the same. 
> 
> Thanks for your reply Daniel unfortunately nohup makes no difference the 
> script still stops with no output being logged -- and also on a 
> different machine (Ubuntu) php -f test.php >test.log 2>&1 & -- works 
> perfectly - seems to be an issue with OSX Lion and the version of PHP 
> that came with the machine -- I cannot compile my own build of PHP 
> because of this problem -> https://bugs.php.net/bug.php?id=60268 -- so I 
> am completely stuck :(

The point is that you need to completely disassociate the process from the tty.
Install the daemonize program, then use it to run your PHP script. See:

http://software.clapper.org/daemonize/

It claims to run under OSx (which is just BSD Unix).

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] PHP script won't run in the background

2011-11-23 Thread Alain Williams
On Wed, Nov 23, 2011 at 06:14:07PM +0100, richard gray wrote:

> Reading symbols for shared libraries + done
> 0x000101d057ee in __ioctl ()
> 
> Any clues? To me it looks like PHP cli is trying to do some I/O but I'm 
> just a dumb developer... :)

ioctl on a tty is typically used to set it into single character at a time mode 
(remove stty's icanon).
It could have decided that since it is a tty then that should be set.

You need a bit more info, get a backtrace with 'where'.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] Parsing the From field

2011-11-19 Thread Alain Williams
On Sat, Nov 19, 2011 at 11:23:59AM -0500, Ron Piggott wrote:
> 
> I am unsure of how to parse first name, last name and e-mail address from the 
> 'From:' field of an e-mail.
> 
> What I am struggling with is if the name has more than two words 
> - Such as the last name being multiple words
> - A name a business or department is given instead of a personal name
> - If the person has included their middle name, middle initial or degrees 
> (“Dr.”)
> - If last name has multiple words
> 
> Also the formatting of the from field changes in various e-mail programs:
> 
> From: Ron Piggott 
> From: "Ron Piggott" 
> From: ron.pigg...@actsministries.org
> From: 
> 
> If there is more than 2 words for the name I would like them to be assigned 
> to the last name.

You can make no such assumption, different people/companies/... do it in 
different ways.
If you really want to have fun look at the different 'norms' from different 
countries.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] Up to date book on PHP security?

2011-11-11 Thread Alain Williams
On Fri, Nov 11, 2011 at 05:01:19PM -0600, Keith Purtell wrote:
> As a PHP newbie, I was advised to get a book by Chris Shiflett titled 
> "Essential PHP Security." I looked at Amazon.com but the book appears to 
> be more than five years old. Should I get something more up to date?

It is a good book -- easy to read, 1/2 day, and gives you a big picture.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] Placing the masterpassword

2011-11-01 Thread Alain Williams
On Tue, Nov 01, 2011 at 02:24:05PM +0100, Florian Müller wrote:
> 
> Hi all
> I got a little question about a good application design in PHP.
> If I use a mysql connection for example, I have to store my mysql-password 
> somewhere in the code. If it's just in the mysql-class, that's not that good, 
> because if somebody changes the functionality, he'd see it.
> I also can't store it in a text file. Until now, I just created a password 
> class where all the passwords are described and i can get them by a 
> get-function.
> Where are passwords stored in the big applications? There has to be at least 
> one big masterpassword somewhere - how can I store it safely? How is this 
> problem solved in big systems in production?

I store things like this in a file above the document root - so not grabbable 
by URL.
Don't store it in the code ... you then end up with the password stored in 
several
places & then difficult to change.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



[PHP] Re: Extending an instantiated class

2011-10-15 Thread Alain Williams
On Sat, Oct 15, 2011 at 03:01:44PM +0100, Alain Williams wrote:
> Well, that is what I think that I need. Please let me explain what I am 
> trying to do
> and tell me how to do it or a better way of doing it.
> ..

I have solved it. The problem is basically one of ensuring that properties are 
the same
value when accessed via the parent or child class ... be that to get or set a 
value.
So I solved the problem by making the properties in the child class references 
to the
ones in the parent class.

Methods are not a problem - inheritance just works fine.

To do this, pass the instance of the parent class to the child class 
constructor and use
a reflection class to determine the properties in the parent class. This will 
not work
properly if the child class overrides a property of the parent class ... this 
does not
worry me.

class Screen {
public $screen;

}

class Form extends Screen {
function __construct(&$s) {
  $sr = new ReflectionClass($s);

  foreach($sr->getProperties(ReflectionProperty::IS_PUBLIC | 
ReflectionProperty::IS_PROTECTED) as $p)
$this->{$p->name} = &$s->{$p->name};
}
}

$s = new Screen();
$s->AddJsVar('Date', '15 Oct 2011');

$f1 = new Form($s);

$f1->screen = 'something'; // this assigns the property in $s.


Comments ?

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



[PHP] Extending an instantiated class

2011-10-15 Thread Alain Williams
Well, that is what I think that I need. Please let me explain what I am trying 
to do
and tell me how to do it or a better way of doing it.

I have an application where a Screen (web page) may contain several Forms. The 
Forms
will want to access properties, etc, from their Screen. So what I want is to do
something like:

class Screen {
private $JavascriptVars = array();

function AddJsVar($name, $val) {
  $this->JavascriptVars[$name] = $val;
}
}

class Form extends Screen {
public $screen;  // Could set to a class Screen

function DefineForm($fName)
.
}

$s = new Screen();
$s->AddJsVar('Date', '15 Oct 2011');

$f1 = new Form($s);
$f1->DefineForm('search');
$f1->AddJsVar('CompanyName', 'IBM');

$f2 = new Form($s);
$f2->DefineForm('login');
$f2->AddJsVar('Error', 'Login failed');

The trouble is that $f1->AddJsVar() will fail, class extention seems not 
designed to work like that.

I could make it work by either:

1) $f1->screen->AddJsVar() --- but I would rather avoid the extra '->screen'.

2) Use of a __call() in class Form -- but that makes things slower.


Any help gratefully received.



I think that to do what I want PHP would need a syntax like:

$f2 = new $s Form();
or
$f2 = $s->new Form();

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



Re: [PHP] Running PHP5 in a PHP4 environment

2011-05-13 Thread Alain Williams
On Fri, May 13, 2011 at 01:22:10AM -0400, Paul M Foster wrote:
> I recently installed some code written for a PHP 5 environment on a
> server which I thought was running PHP 5. It was a form which should
> ...
> would issue a syntax warning or something similar. Is there some way I
> can squeeze some identifiable error code out of PHP 4 to indicate it's
> hit PHP 5 code it doesn't understand?

Would your time not be better spent getting the system upgraded to PHP5 ?

PHP 4 was depricated some time ago.

-- 
Alain Williams
Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT 
Lecturer.
+44 (0) 787 668 0256  http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information: 
http://www.phcomp.co.uk/contact.php
#include 

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



[PHP] Removing/unsetting session variables.

2003-12-24 Thread Alain Williams
I have several variables that I set in a session - to record that a user is logged in.
I want to be able to unset them - when they log out.

$_SESSION['PERMS_USER'] = 'fred';
Sets the variable quite nicely, I can also change it and the change is recorded.
I cannot unset it. I have tried (in various combinations):

unset($_SESSION['PERMS_USER']);
unset($HTTP_SESSION_VARS['PERMS_USER']);
session_unregister($SESSION['PERMS_USER']);
session_unregister($HTTP_SESSION_VARS['PERMS_USER']);

None of which have any effect.

What should I do ?

Thanks

Merry Christmas.

-- 
Alain Williams

#include 

FATHERS-4-JUSTICE - Campaigning for equal rights for parents and the
best interests of our children. See http://www.fathers-4-justice.org

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



[PHP] include_path

2003-12-22 Thread Alain Williams
Is there a way of modifying the include_path within a script, I want to add to it,
not completely change it. The sort of thing that I want to do is equivalent to
the following bit of shell code:

PATH="$HOME/bin:$PATH"

ie add a user specific part to the path - so that a production/test 'require'
gets the production/test version of a file.

Please CC me on any reply since I don't subscribe to this list.

Thanks

-- 
Alain Williams

#include 

FATHERS-4-JUSTICE - Campaigning for equal rights for parents and the
best interests of our children. See http://www.fathers-4-justice.org

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



[PHP] Default mode -- Output buffering ??

2003-07-17 Thread Alain Williams
I recently upgraded from RedHat 9 supplied 4.1.2 to from_the_net 4.3.2.
I am running the command line version (#!/usr/bin/php) as a .cgi rather than
directly in apache as a module (with a .php suffix).

What I find is that the first line after #!/usr/bin/php needs to be:
Content-type: text/html

This used to be generated automatically, and still is in apache module version.

The whole thing acts differently, phpinfo() generates text output and not HTML.

It seems as if the /usr/bin/php has decided that it is not generating web output
any more -- for some reason.

Is there a build/configure option that I can set to get the original behaviour or
a command line switch to specify 'html on' or something ? I have looked but cannot
find anything.

Thanks in advance.

-- 
Alain Williams

#include 

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



Re: [PHP] Call by reference to function arguments

2003-07-07 Thread Alain Williams
On Mon, Jul 07, 2003 at 06:20:42PM +0100, David Otton wrote:
> On Mon, 7 Jul 2003 17:36:26 +0100, you wrote:
> 
> >I want to write a function (as I have written in several other languages) that
> >obtains it's arguments dynamically (using func_get_arg()) and then assigns to that
> >argument. Think of the way that scanf() works -- that sort of thing.
> >
> >I have distilled what I want to do in the code below. foo adds 1 to all of it's 
> >arguments.
> >
> >function foo () {
> > $count = func_num_args();
> > for($i = 0; $i <= $count; $i++) {
> > $var = func_get_arg($i);
> > // The following line should do it, but throws a syntax error
> > &$var = $var + 1;
> > }
> >}
> >
> >$a = '1';
> >$b = '2';
> >$c = '3';
> >
> >foo($a, $b, $c);
> >
> >What I am doing is quite different than the above (and more complex), but I will be 
> >able
> >to achieve what I want if I can get the above to work.
> 
> Well this would work
> 
> function foo () {
>   $count = func_num_args();
>   for($i = 0; $i < $count; $i++) {
>   $var = func_get_arg($i);
>   $var = $var + 1;
> echo ($var);
>   }
> }
> 
> But I get the feeling you're trying to modify the elements in-place? Any
> particular reason?
> 
> If it's because you want to return multiple values from the function,
> consider this:
> 
> function foo () {
> $args = array();
> for ($i = 0; $i < func_num_args(); $i++) {
>   $args[] = func_get_arg($i);
>   }
> 
> $args = array_map (create_function ('$a','return($a+1);'), $args);
> 
> return ($args);
> }
> 
> list ($a, $b, $c) = foo(1, 2, 3);
> 
> echo ("$a, $b, $c");

No, the reason that I want to do it is for the same reason that sscanf() does it -- I 
want
to change the values of the variables that are passed to it.

-- 
Alain Williams

#include 

FATHERS-4-JUSTICE - Campaigning for equal rights for parents and the
best interests of our children. See http://www.fathers-4-justice.org

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



[PHP] Call by reference to function arguments

2003-07-07 Thread Alain Williams
Hi,

I want to write a function (as I have written in several other languages) that
obtains it's arguments dynamically (using func_get_arg()) and then assigns to that
argument. Think of the way that scanf() works -- that sort of thing.

I have distilled what I want to do in the code below. foo adds 1 to all of it's 
arguments.

function foo () {
$count = func_num_args();
for($i = 0; $i <= $count; $i++) {
$var = func_get_arg($i);
// The following line should do it, but throws a syntax error
&$var = $var + 1;
}
}

$a = '1';
$b = '2';
$c = '3';

foo($a, $b, $c);

What I am doing is quite different than the above (and more complex), but I will be 
able
to achieve what I want if I can get the above to work.

-- 
Alain Williams

#include 

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