[PHP] test

2003-08-16 Thread adam
tst

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


[PHP] call function as variable

2003-08-16 Thread adam
Hi!

I have folowing function which they are a member in a class.

function foo(){
something
}
function zoo(){
something else
}
and i have a array such:

$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();

I have tried this this, it will not working. But is there any other way 
to do something like this!!

cheers

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


[PHP] Re: How do I call a function in a Class from another function inthe same class

2003-08-16 Thread adam
 typically problem!
have you used $this-tehotherfunction();
or just use therotherfunction();???
if you call from your class to a members method , you have use $this!!!
And read more about oo-method!
cheers

Donpro wrote:
Hi,
 
I have two functions in a class where one calls the other.  When creating my
object I get an error:
 
Call to undefined function
 
I dont understand why the function can't be seen?
 
 
Thanks,
Don

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.507 / Virus Database: 304 - Release Date: 8/4/2003
 



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


php-general Digest 16 Aug 2003 08:16:35 -0000 Issue 2239

2003-08-16 Thread php-general-digest-help

php-general Digest 16 Aug 2003 08:16:35 - Issue 2239

Topics (messages 159743 through 159789):

Re: Segmentation Fault
159743 by: Jay Blanchard
159758 by: Curt Zirzow

Checkboxes
159744 by: Cesar Aracena
159745 by: Matt Babineau
159746 by: Cesar Aracena
159747 by: Wouter van Vliet
159748 by: CPT John W. Holmes
159749 by: Chris Boget

Re: Screen Resoultion
159750 by: Kris Yates
159751 by: Chris W. Parker
159754 by: Kris Yates

Re: How to get data from database with a click
159752 by: Comex
159786 by: Viraj Kalinga Abayarathna

Re: PCRE regexp bug ?
159753 by: tpc.csua.berkeley.edu
159756 by: tpc.csua.berkeley.edu
159757 by: Curt Zirzow

Re: Function arguments
159755 by: Jim Lucas

Re: Foreach POST VARS problem
159759 by: Catalin Trifu
159760 by: Curt Zirzow
159761 by: Catalin Trifu

Re: If you ever had a Vic20
159762 by: John Taylor-Johnston
159763 by: John Taylor-Johnston
159764 by: Matt Babineau
159769 by: John Taylor-Johnston

Bug in Ereg?
159765 by: Kris Yates
159766 by: Kris Yates
159767 by: Jennifer Goodie
159768 by: Curt Zirzow
159770 by: Marek Kilimajer
159771 by: Wouter van Vliet
159772 by: Wouter van Vliet

executing a shell command within a function
159773 by: Sævar Öfjörð
159774 by: Mike Brum

Installing How-To
159775 by: Rodney Davis

mysql_num_rows
159776 by: John Taylor-Johnston
159777 by: CPT John W. Holmes

Help - Translation Troubles : cvs / chapters / streams.structs.xml
159778 by: Hafid

Help - Translation Troubles : cvs / chapters / streams.common.xml
159779 by: Hafid

HOW DO U SPLIT UP LARGE STRINGS?
159780 by: John Ryan
159781 by: jabber.raditha.com
159782 by: CPT John W. Holmes
159783 by: John Ryan

How to write my own php extensions
159784 by: Dennis Lee
159785 by: jabber.raditha.com

test
159787 by: adam

call function as variable
159788 by: adam

Re: How do I call a function in a Class from another function in the same class
159789 by: adam

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
[snip]
I am running a PHP script from the command line that is returning 
Segmentation Fault.  I run a lot of script from the command line and
have 
never seen this before.  I don't even know where to begin.

I know that PHP is set up to run scripts from the command line and plent
of 
other scripts run.

This particular script is not doing anything out of the ordinary.  It is

opening a database connection, opening a .csv file and inserting rows
into 
the database.  How in the world could this Seg Fault?
[/snip]

segmentation fault: n.
[Unix] 

1. [techspeak] An error in which a running program attempts to access
memory not allocated to it and core dumps with a segmentation violation
error. This is often caused by improper usage of pointers in the source
code, dereferencing a null pointer, or (in C) inadvertently using a
non-pointer variable as a pointer.

This script has no doubt worked before, so some other codition exists.
Things like this are generally created by infinite loops or improper
variables.
---End Message---
---BeginMessage---
* Thus wrote Jackson Miller ([EMAIL PROTECTED]):
 I am running a PHP script from the command line that is returning 
 Segmentation Fault.  I run a lot of script from the command line and have 
 never seen this before.  I don't even know where to begin.

http://bugs.php.net/how-to-report.php

 
 I know that PHP is set up to run scripts from the command line and plent of 
 other scripts run.
 
 This particular script is not doing anything out of the ordinary.  It is 
 opening a database connection, opening a .csv file and inserting rows into 
 the database.  How in the world could this Seg Fault?

Obtain a backtrace of the program (assuming your on unix):

Run gdb with php as the program:

 gdb /path/to/php


when the gdb prompt somes up type the word 'run' with the options
and filename you would normally would pass to php:

(gdb) run [options] phpfile.php

Once it finishes with your crash then type 'bt':

(gdb) bt


To kinda understand what this all means you can read this
documentation under 'Locating which function call cases fault':

http://bugs.php.net/bugs-generating-backtrace.php


HTH,

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.
---End Message---
---BeginMessage---
Hi all,
 
I am wondering what would be the best way to handle checkboxes. I am
making a site that will display several items in a 20-items-per-page

[PHP] How to connect to DB

2003-08-16 Thread murugesan
Hello all,
I have some existing php pages already. Now I want to change the DB
to point to another DB.

I have changed the include_path in php.ini file to point to /home/config
Also I changed the constant db_name defined in a file in
/home/config/con.php to point to new DB.

[snip]

include con.php
@mysql_pconnect(db_host,db_user,db_pass);
mysql_select_db (db_name) or die (could not select db);



//contents of con.php

?php
  define('db_host','localhost');
  define('db_name','newdb') ;
  define('db_user','scott') ;
  define('db_pass','tiger') ;
  define('db_type','mysql') ;
 ?



Also I restarted the apache.
But it is still accessing the old DB.
What are all the changes that I have to make. other than these changes.

Regards,
Murugesan.


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



Re: [PHP] call function as variable

2003-08-16 Thread John W. Holmes
adam wrote:
Hi!

I have folowing function which they are a member in a class.

function foo(){
something
}
function zoo(){
something else
}
and i have a array such:

$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();
Try:

{$object-$test[1]}();

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals  www.phparch.com





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


[PHP] better understanding of ereg_replace and other functions

2003-08-16 Thread Binay Agarwal
Hi everybody,

Lot of places in manual i came across using ereg_replace or ereg is very resource 
intensive and hence its better to use preg_replace or str_replace or strpos if 
they do the jobs.

Now i am very curious to look at the source code (implementation) of these function so 
as to be able to decide the right choice for me. Can any one of you tell me where to 
find the source code of these functions. Do they require special privileges ??

Please help me out


Binay


RE: [PHP] better understanding of ereg_replace and other functions

2003-08-16 Thread Boaz Yahav
Try these :

preg_replace
http://www.weberdev.com/AdvancedSearch.php?searchtype=examplesort=examp
leexample=preg_replace

str_replace
http://www.weberdev.com/AdvancedSearch.php?searchtype=examplesort=examp
leexample=str_replace

strpos
http://www.weberdev.com/AdvancedSearch.php?searchtype=examplesort=examp
leexample=strpos

Sincerely
 
berber
 
Visit http://www.weberdev.com/ Today!!!
To see where PHP might take you tomorrow.
Share your code : http://addexample.weberdev.com
Search for PHP Code from your browser http://toolbar.weberdev.com




-Original Message-
From: Binay Agarwal [mailto:[EMAIL PROTECTED] 
Sent: Saturday, August 16, 2003 2:39 AM
To: [EMAIL PROTECTED]
Subject: [PHP] better understanding of ereg_replace and other functions


Hi everybody,

Lot of places in manual i came across using ereg_replace or ereg is
very resource intensive and hence its better to use preg_replace or
str_replace or strpos if they do the jobs.

Now i am very curious to look at the source code (implementation) of
these function so as to be able to decide the right choice for me. Can
any one of you tell me where to find the source code of these functions.
Do they require special privileges ??

Please help me out


Binay

 


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



[PHP] preg_replace question

2003-08-16 Thread Jean-Christian IMbeault
I found this nice preg_replace function that replaces all occurrences of 
an HTML anchor (a href=...) with a link to another PHP script that log 
the link and then sends the user on his merry way to the the appropriate 
page/site:

preg_replace(
  #a href=(\|')http://([^\']+)(\|')#ime,
  'a href=\/exit.php?url=.base64_encode(\'\\2\').\',
  $originalLink
);
I'd like to modify this expression so that it does the same thing but 
*only* if the link is not to a specific page. I.e. I would like to 
replace all links *unless* the link was to, for example, www.mydomain.com.

How can I achieve this with a regexp? I'm not very good at 'negative' 
regexp ...

Thanks,

Jean-Christian Imbeault

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


Re: [PHP] preg_replace question

2003-08-16 Thread [EMAIL PROTECTED]
Then use a simple strstr to first find out if the string does contain 
mydomain.com :-)

Jean-Christian IMbeault wrote:

I found this nice preg_replace function that replaces all occurrences 
of an HTML anchor (a href=...) with a link to another PHP script that 
log the link and then sends the user on his merry way to the the 
appropriate page/site:

preg_replace(
  #a href=(\|')http://([^\']+)(\|')#ime,
  'a href=\/exit.php?url=.base64_encode(\'\\2\').\',
  $originalLink
);
I'd like to modify this expression so that it does the same thing but 
*only* if the link is not to a specific page. I.e. I would like to 
replace all links *unless* the link was to, for example, 
www.mydomain.com.

How can I achieve this with a regexp? I'm not very good at 'negative' 
regexp ...

Thanks,

Jean-Christian Imbeault




--

Raditha Dissanayake
-
http://www.radinks.com/sftp/
Lean and mean Secure FTP applet with Graphical User Inteface.
just 150 Kilo Bytes


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


[PHP] imagecreatefromjpeg() problems

2003-08-16 Thread J-K
  Hi!

  I've made a little script to make thumbnails which worked before the
summer, but now I get this errormessage:

  bFatal error/b:  Call to undefined function:
imagecreatefromjpeg() in
b/usr/local/others/www.stud.users/mark/gfx/create_tn.php/b on line
b15/b

  First I thought they had done something with the servers, because I
haven't touched the code. But I checked the GD-version and got this:
  GD Version: bundled (2.0.12 compatible)

  Shouldn't version 2.0.12 support imagecreatefromjpeg()?

  Is there any way I can get around this?

  In advance thanks!
  Best regards
  Jan-Kristian Markiewicz



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



Re: [PHP] call function as variable

2003-08-16 Thread adam
I got this error:

Parse error: parse error, unexpected '{' in ...

Cheers

John W. Holmes wrote:

adam wrote:

Hi!

I have folowing function which they are a member in a class.

function foo(){
something
}
function zoo(){
something else
}
and i have a array such:

$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();


Try:

{$object-$test[1]}();



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


Re: [PHP] call function as variable

2003-08-16 Thread David Otton
On Sat, 16 Aug 2003 07:58:27 +0200, you wrote:

I have folowing function which they are a member in a class.

function foo(){
something
}

function zoo(){
something else
}


and i have a array such:

$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();

The fact that you say $object-$test suggests that foo() and zoo() are
methods of a class? The following code snippet contains just about every
mechanism for calling a method of a class that there is. The one you'll
probably want is

call_user_func (array ($C, 'B'), 'call 4');

?

/* Class A has method B */
class A {
function B ($s = None) {
echo (pinput : $s/p);
}
}

/* $C is an instance of A */
$C = new A ();

/* $D is an array of strings */
$D = array ('item 1', 'item 2', 'item 3', 'item 4');

/* invoke A::B */
A::B ('call 1');

/* invoke $C-B */
$C-B ('call 2');

/* invoke A::B via call_user_func() */
call_user_func (array ('A', 'B'), 'call 3');

/* invoke $C-B via call_user_func() */
call_user_func (array ($C, 'B'), 'call 4');

/* invoke A::B via call_user_func_array() */
call_user_func_array (array ('A', 'B'), array('call 5'));

/* invoke $C-B via call_user_func_array() */
call_user_func_array (array ($C, 'B'), array('call 6'));

/* apply A::B to $D via array_walk() */
array_walk ($D, array ('A', 'B'));

/* apply $C-B to $D via array_walk() */
array_walk ($D, array ($C, 'B'));

?


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



Re: [PHP] call function as variable

2003-08-16 Thread Michael Sims
On Sat, 16 Aug 2003 07:58:27 +0200, you wrote:

$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();

I've never used this myself, but this should work:

call_user_func($object, $test[1]);

See:

http://www.php.net/manual/en/function.call-user-func.php

HTH

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



Re: [PHP] call function as variable

2003-08-16 Thread adam
Tanks a lot!
this is exactly that i want!!
Cheers

Michael Sims wrote:

On Sat, 16 Aug 2003 07:58:27 +0200, you wrote:


$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();


I've never used this myself, but this should work:

call_user_func($object, $test[1]);

See:

http://www.php.net/manual/en/function.call-user-func.php

HTH


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


Re: [PHP] call function as variable

2003-08-16 Thread adam
Tanks a lot!
This was exactly that i wanted!
Cheers

David Otton wrote:

On Sat, 16 Aug 2003 07:58:27 +0200, you wrote:


I have folowing function which they are a member in a class.

function foo(){
something
}
function zoo(){
something else
}
and i have a array such:

$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();


The fact that you say $object-$test suggests that foo() and zoo() are
methods of a class? The following code snippet contains just about every
mechanism for calling a method of a class that there is. The one you'll
probably want is
	call_user_func (array ($C, 'B'), 'call 4');

?

/* Class A has method B */
class A {
function B ($s = None) {
echo (pinput : $s/p);
}
}
/* $C is an instance of A */
$C = new A ();
/* $D is an array of strings */
$D = array ('item 1', 'item 2', 'item 3', 'item 4');
/* invoke A::B */
A::B ('call 1');
/* invoke $C-B */
$C-B ('call 2');
/* invoke A::B via call_user_func() */
call_user_func (array ('A', 'B'), 'call 3');
/* invoke $C-B via call_user_func() */
call_user_func (array ($C, 'B'), 'call 4');
/* invoke A::B via call_user_func_array() */
call_user_func_array (array ('A', 'B'), array('call 5'));
/* invoke $C-B via call_user_func_array() */
call_user_func_array (array ($C, 'B'), array('call 6'));
/* apply A::B to $D via array_walk() */
array_walk ($D, array ('A', 'B'));
/* apply $C-B to $D via array_walk() */
array_walk ($D, array ($C, 'B'));
?



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


[PHP] pop3 functions

2003-08-16 Thread andu
Someone asked for the pop3 functions I put togather (lost your message),
please contact me off list, It works fine with my server but no
guaranties though there should be no problems.

I take the opportunity to express my 2 major problems I found with php
in the 2 months I've been using it. 
First is the naming of functions (whoever was the illiterate one who
invented them) definitely not meant to be remembered or to represent
what they actually do. It's a shame to have to fill our minds with such
garbage: strcasecmp, strchr, strcmp, strcoll, strcspn, stripos, stristr,
strspn, strstr, to take just a few. A programming language has already
its problems for not being natural, no need to make it even more so.
Second, it the array overkill.
Nevertheless, I love it.

-- 
Regards, Andu Novac

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



RE: [PHP] better understanding of ereg_replace and other functions

2003-08-16 Thread Wouter van Vliet
You can just download the source distribution of php, and on a linux
commandline do:

grep -inr preg_replace *

You'll find all occurances of preg_replace, including it's declaratin, which
I have copies below. It seems like it's being passed thru to another
function .. Which is also on the same file: ext/pcre/php_pcre.c (I've
searched a PHP5.0 sourcetree)

    /* {{{ proto string preg_replace(mixed regex, mixed replace, mixed
subject [, int limit])
   1112Perform Perl-style regular expression replacement. */
   1113 PHP_FUNCTION(preg_replace)
   1114 {
   1115 preg_replace_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
   1116 }
   1117 /* }}} */

Greetz,
Wouter

-Oorspronkelijk bericht-
Van: Binay Agarwal [mailto:[EMAIL PROTECTED]
Verzonden: zaterdag 16 augustus 2003 2:39
Aan: [EMAIL PROTECTED]
Onderwerp: [PHP] better understanding of ereg_replace and other
functions


Hi everybody,

Lot of places in manual i came across using ereg_replace or ereg is very
resource intensive and hence its better to use preg_replace or
str_replace or strpos if they do the jobs.

Now i am very curious to look at the source code (implementation) of these
function so as to be able to decide the right choice for me. Can any one of
you tell me where to find the source code of these functions. Do they
require special privileges ??

Please help me out


Binay



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



Re: [PHP] Installing How-To

2003-08-16 Thread Jaap van Ganswijk
At 2003-08-15 15:12 -1000, Rodney Davis wrote:
Does anyone know of a good howto on installing
php w/ GD and phplib etc on a Redhat box?

I have just upgraded my (Mandrake) system by doing:
- Upgrading from Mandrake 9.0 to 9.1 using the CD's
  that came with the UK Linux Format magazine of
  june 2003:
  www.linuxformat.co.uk
- Then I installed the Apache Source version 2.0.45
  from the CD-ROM that came with PHP Magazine 4.2003
  www.php-mag.net
  and I compiled it, which went very smoothly
- Then I installed the PHP Source version 4.3.2
  from the same CD-ROM and compiled it. (Which
  takes more tinkering.)

The complete process took a while, especially because
I first tried to install from binaries, but it works
very well now, including a GD that supports true color
images etc.

I'm not saying that I think that Mandrake is currently
better than RedHat, but when I switched from Redhat
(5.2 or 6?) to Mandrake 7.2 (?) some years ago it's
installation process was even simpler than that of
RedHat (on which it is based).

In my experience it's a lot of work to upgrade all the
libraries by hand, because they are much too interdependent
and hard to locate on the WWW.

Some tips:
- Install Apache and PHP from source.
- Reboot your computer from time to time between installing
  things and changing .ini and .conf files, just restarting
  Apache is sometimes not enough it seems.
- Put a personal readme file in each directory, describing
  what you did to get things working. (This will help a lot
  next time.)

BTW. There is a separate mailing list about installing PHP.
You'd better ask there and look in it's archive etc.

Greetings,
Jaap


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



php-general Digest 16 Aug 2003 20:20:29 -0000 Issue 2240

2003-08-16 Thread php-general-digest-help

php-general Digest 16 Aug 2003 20:20:29 - Issue 2240

Topics (messages 159790 through 159804):

How to connect to DB
159790 by: murugesan

Re: call function as variable
159791 by: John W. Holmes
159797 by: adam
159798 by: David Otton
159799 by: Michael Sims
159800 by: adam
159801 by: adam

better understanding of ereg_replace and other functions
159792 by: Binay Agarwal
159793 by: Boaz Yahav
159803 by: Wouter van Vliet

preg_replace question
159794 by: Jean-Christian IMbeault
159795 by: jabber.raditha.com

imagecreatefromjpeg() problems
159796 by: J-K

pop3 functions
159802 by: andu

Re: Installing How-To
159804 by: Jaap van Ganswijk

Administrivia:

To subscribe to the digest, e-mail:
[EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]

To post to the list, e-mail:
[EMAIL PROTECTED]


--
---BeginMessage---
Hello all,
I have some existing php pages already. Now I want to change the DB
to point to another DB.

I have changed the include_path in php.ini file to point to /home/config
Also I changed the constant db_name defined in a file in
/home/config/con.php to point to new DB.

[snip]

include con.php
@mysql_pconnect(db_host,db_user,db_pass);
mysql_select_db (db_name) or die (could not select db);



//contents of con.php

?php
  define('db_host','localhost');
  define('db_name','newdb') ;
  define('db_user','scott') ;
  define('db_pass','tiger') ;
  define('db_type','mysql') ;
 ?



Also I restarted the apache.
But it is still accessing the old DB.
What are all the changes that I have to make. other than these changes.

Regards,
Murugesan.

---End Message---
---BeginMessage---
adam wrote:
Hi!

I have folowing function which they are a member in a class.

function foo(){
something
}
function zoo(){
something else
}
and i have a array such:

$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();
Try:

{$object-$test[1]}();

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

PHP|Architect: A magazine for PHP Professionals  www.phparch.com




---End Message---
---BeginMessage---
I got this error:

Parse error: parse error, unexpected '{' in ...

Cheers

John W. Holmes wrote:

adam wrote:

Hi!

I have folowing function which they are a member in a class.

function foo(){
something
}
function zoo(){
something else
}
and i have a array such:

$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();


Try:

{$object-$test[1]}();


---End Message---
---BeginMessage---
On Sat, 16 Aug 2003 07:58:27 +0200, you wrote:

I have folowing function which they are a member in a class.

function foo(){
something
}

function zoo(){
something else
}


and i have a array such:

$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();

The fact that you say $object-$test suggests that foo() and zoo() are
methods of a class? The following code snippet contains just about every
mechanism for calling a method of a class that there is. The one you'll
probably want is

call_user_func (array ($C, 'B'), 'call 4');

?

/* Class A has method B */
class A {
function B ($s = None) {
echo (pinput : $s/p);
}
}

/* $C is an instance of A */
$C = new A ();

/* $D is an array of strings */
$D = array ('item 1', 'item 2', 'item 3', 'item 4');

/* invoke A::B */
A::B ('call 1');

/* invoke $C-B */
$C-B ('call 2');

/* invoke A::B via call_user_func() */
call_user_func (array ('A', 'B'), 'call 3');

/* invoke $C-B via call_user_func() */
call_user_func (array ($C, 'B'), 'call 4');

/* invoke A::B via call_user_func_array() */
call_user_func_array (array ('A', 'B'), array('call 5'));

/* invoke $C-B via call_user_func_array() */
call_user_func_array (array ($C, 'B'), array('call 6'));

/* apply A::B to $D via array_walk() */
array_walk ($D, array ('A', 'B'));

/* apply $C-B to $D via array_walk() */
array_walk ($D, array ($C, 'B'));

?

---End Message---
---BeginMessage---
On Sat, 16 Aug 2003 07:58:27 +0200, you wrote:

$test = array(1=foo,2=zoo);

and i want to call the fuction foo() and zoo something like;

$object-$test[1]();

I've never used this myself, but this should work:

call_user_func($object, $test[1]);

See:

http://www.php.net/manual/en/function.call-user-func.php

HTH
---End Message---
---BeginMessage---
Tanks a lot!
this is exactly that i want!!
Cheers

Michael Sims wrote:

On Sat, 16 Aug 2003 07:58:27 +0200, you wrote:


$test = array(1=foo,2=zoo);

Re: [PHP] redhat 8: upgrade php from 4.2.2 to 4.3.2

2003-08-16 Thread Jaap van Ganswijk
At 2003-08-15 09:31 -0700, Chris W. Parker wrote:
Hello eveyone.

I want to upgrade my php install from 4.2.2 to 4.3.2. I'm pretty new to
linux so I don't know how to install from source and I haven't been able
to find any Redhat 8 rpm's.

Can someone please give me instructions as to what I should do? (Maybe
links to a site where I can find the correct rpm file or instructions on
how to install a new version of php from source.. etc.)

I have just upgraded my (Mandrake) system by doing:
- Upgrading from Mandrake 9.0 to 9.1 using the CD's
  that came with the UK Linux Format magazine of
  june 2003:
  www.linuxformat.co.uk
- Then I installed the Apache Source version 2.0.45
  from the CD-ROM that came with PHP Magazine 4.2003
  www.php-mag.net
  and I compiled it, which went very smoothly
- Then I installed the PHP Source version 4.3.2
  from the same CD-ROM and compiled it. (Which
  takes more tinkering.)

The complete process took a while, especially because
I first tried to install from binaries, but it works
very well now, including a GD that supports true color
images etc.

I'm not saying that I think that Mandrake is currently
better than RedHat, but when I switched from Redhat
(5.2 or 6?) to Mandrake 7.2 (?) some years ago it's
installation process was even simpler than that of
RedHat (on which it is based).

In my experience it's a lot of work to upgrade all the
libraries by hand, because they are much too interdependent
and hard to locate on the WWW.

Some tips:
- Install Apache and PHP from source.
- Reboot your computer from time to time between installing
  things and changing .ini and .conf files, just restarting
  Apache is sometimes not enough it seems.
- Put a personal readme file in each directory, describing
  what you did to get things working. (This will help a lot
  next time.)

BTW. There is a separate mailing list about installing PHP.
You'd better ask there and look in it's archive etc.

Greetings,
Jaap


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



[PHP] Sessions

2003-08-16 Thread Peda
Hi!!

I have some problem on my site.

When I'm using this PHP script:

?php
session_start();
session_register( aUser, aAccount );
$aUser  = Cidnie;
$aAccount   = 1016;
?
html
head
 titleGetting Started With Sessions: Page 1/title
/head
body
?php
print( Current User: $aUserbr );
print( Current Account: $aAccountbr );
?
brbr
a href=listing2.phtmlGo to page 2/a
/body
/html

I'm getting this warning messages:

Warning: session_start(): open(/tmp/sess_cbd07ca5b53347ca5003404053754bde,
O_RDWR) failed: Permission denied (13) in
/home2/pena/public_html/listing1.php on line 2

Warning: session_start(): Cannot send session cookie - headers already sent
by (output started at /home2/pena/public_html/listing1.php:2) in
/home2/pena/public_html/listing1.php on line 2

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at /home2/pena/public_html/listing1.php:2) in
/home2/pena/public_html/listing1.php on line 2

Warning: Unknown(): open(/tmp/sess_cbd07ca5b53347ca5003404053754bde, O_RDWR)
failed: Permission denied (13) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that
the current setting of session.save_path is correct (/tmp) in Unknown on
line 0


It looks like I don't have permission to write in /tmp/ directory.
Can I change that permission?

Greetings, Peda!!!



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



Re: [PHP] Sessions

2003-08-16 Thread Jaap van Ganswijk
At 2003-08-16 23:28 +0200, Peda wrote:
I have some problem on my site.

When I'm using this PHP script:

?php
session_start();
session_register( aUser, aAccount );
$aUser  = Cidnie;
$aAccount   = 1016;
?
?php print( Current User: $aUser
 ); print( Current Account: $aAccount
 ); ? 

listing2.htmGo to page 2 
I'm getting this warning messages:

Warning: session_start(): open(/tmp/sess_cbd07ca5b53347ca5003404053754bde,
O_RDWR) failed: Permission denied (13) in
/home2/pena/public_html/listing1.php on line 2

Warning: session_start(): Cannot send session cookie - headers already sent
by (output started at /home2/pena/public_html/listing1.php:2) in
/home2/pena/public_html/listing1.php on line 2

It looks like I don't have permission to write in /tmp/ directory.
Can I change that permission?

Normally you can only change this when you're the
system manager ('root'), but I'm looking now on
the system that hosts one of my sites and there
I seem to own the /tmp directory that I and my
applications see. It's a kind of virtual private
Unix server.

When you have a shell login, try this:
- cd /tmp
- chown . your_user_name

This probably gives an error warning.

- chmod u+rw .

This probably also gives an error warning.

There are also permission commands under FTP I think.

Otherwise contact your system manager.

There are a lot of applications like 'vi' that
don't work or don't work properly without
read and write access to the /tmp directory.

By the way, your second problem about not being
able to send the cookies can be solved by putting
ob_start(); as the first command in your PHP-file.
Make sure you really insert this as the first command.
You can't even output an empty line first for example
in the HTML part (so outside of the ?php and ?),
also not in an include file.

You can read much more about this in the manual
under output buffering and the header() function
etc.

Greetings,
Jaap


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



Re: [PHP] imagecreatefromjpeg() problems

2003-08-16 Thread Jaap van Ganswijk
At 2003-08-16 14:35 +0200, J-K wrote:
I've made a little script to make thumbnails which worked before the
summer, but now I get this errormessage:

bFatal error/b:  Call to undefined function:
imagecreatefromjpeg() in
b/usr/local/others/www.stud.users/mark/gfx/create_tn.php/b on line
b15/b

First I thought they had done something with the servers, because I
haven't touched the code. But I checked the GD-version and got this:
  GD Version: bundled (2.0.12 compatible)

  Shouldn't version 2.0.12 support imagecreatefromjpeg()?

Only when jpeg support has been compiled into
the PHP version that is running on your system.
It doesn't seem to be.

Is there any way I can get around this?

Try if png support is enabled. But you'd have
to convert your jpeg's I guess and png's are
probably much bigger because they are
non-lossy (?). But it depends on your images
being photo-like and not drawing-like.

Otherwise you'll have to ask your system
manager to fix the problem.

BTW. you shouldn't indent paragraphs in emails,
because it makes quoting them very messy, or
the person answering your mail has to edit out
the indentations (as I have done above).

Greetings,
Jaap


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



Re: [PHP] Sessions

2003-08-16 Thread Curt Zirzow
* Thus wrote Jaap van Ganswijk ([EMAIL PROTECTED]):
 At 2003-08-16 23:28 +0200, Peda wrote:
 
 When you have a shell login, try this:
 - cd /tmp
 - chown . your_user_name
 
 This probably gives an error warning.
 
 - chmod u+rw .

Don't set your /tmp directoy to those settings. /tmp is a system
directory and should not be owned by any paticular user nor have rw
permissions for a paticular user.

Refer to your OS manual or contact your system administrator and
have him set the proper permissions on /tmp
 

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] better understanding of ereg_replace and other functions

2003-08-16 Thread Curt Zirzow
* Thus wrote Binay Agarwal ([EMAIL PROTECTED]):
 Hi everybody,
 
 Lot of places in manual i came across using ereg_replace or ereg is very 
 resource intensive and hence its better to use preg_replace or str_replace or 
 strpos if they do the jobs.
 

I believe the use of ereg_replace in the samples you see is mainly
due to the fact that not until recently has preg_* function been
enabled by default. So it would make sense for the manual to use
examples with ereg_* functions so the example would be garuenteed
to work.

I would even suggest someone to use str_replace over preg_replace.
The fact being that anytime you call a regular expression function
it has to compile the expression and then apply that compiled
expression to the string.  Where the str_replace is directly
manipulating the  string which is quicker than preg_replace's
method. The only time the overhead is acceptable would be when
you're string is not entirely known, so:

  preg_replace('foo-bar-', '', $str);

Can simply be changed to:
  
  str_replace('foo-bar-', '', $str);

The expression, however:
  preg_replace('foo-\w+-', '', $str);

Can't be done with str_replace.

As for the resouce usage vs. ereg and preg, I believe it is
entirely the nature of the libraries that they use.  I don't think
the source of the functions will reveal too much. 

just a few of my thoughts on this subject.

Thanks for your time.

Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] Sessions

2003-08-16 Thread Jaap van Ganswijk
At 2003-08-16 22:45 +, Curt Zirzow wrote:
* Thus wrote Jaap van Ganswijk ([EMAIL PROTECTED]):
 At 2003-08-16 23:28 +0200, Peda wrote:
 
 When you have a shell login, try this:
 - cd /tmp
 - chown . your_user_name
 
 This probably gives an error warning.
 
 - chmod u+rw .

Don't set your /tmp directoy to those settings. /tmp is a system
directory and should not be owned by any paticular user nor have rw
permissions for a paticular user.

You're missing some points here:
- When everything is organized okay, he can't make
  himself the owner of /tmp, so trying it doesn't
  hurt.
- But it isn't organized okay and he is asking how
  he can check/change it.
- It doesn't hurt when the /tmp directory is from a
  particular user as long as every one has read and
  write permission. Root and programs running with
  root-permissions can do what they want anyway.
- If he would manage to own the /tmp directory,
  changing his own 'u'=user permissions don't
  affect the permissions of others, but it would
  help him to solve his problem (and isolate the
  problem in case he would want a more fundamental
  solution).

Refer to your OS manual

He wrote that he had problems with his site (and
not his server) so I assumed he was using the
server of a hoster and not his own system.

or contact your system administrator and
have him set the proper permissions on /tmp

Yes, as I also suggested he should contact his
system administrator when he can't solve the
problem using the described experiment.

But when he is on a virtual private server like me
(with no other users) he might also want to solve
the problem himself in the manner that I described.

On a virtual server each user has kind-of a complete
Unix file-system for his personal use, fully
separated from that of the other users. So each
user has his own /tmp directory. It doesn't matter
much who owns it then. In my case, my hoster already
made me the owner of the /tmp directory for example.

BTW. The disadvantage of this system is that whatever
is in the /tmp directory is part of one's quotum and
normally it isn't and one can use the /tmp directory
to use much more harddisk space than the quotum
allows, for example for expanding compressed archives
etc.

Greetings,
Jaap


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



RE: [PHP] Sessions

2003-08-16 Thread Wouter van Vliet
As others have pointed out already, your problem indeed is about not being
able to write in the tmp directory. Also, as others have pointed out, if
it's not your server you would not be able to change file permissions of the
/tmp directory. Your solution is probably found in changing the path where
php saves session data.

ini_set('session.save_path', '/full/path/to/your/own/tmp/directory');

Of course you change the path to your own path. That would solve it for the
scripts you have that command in. If the settings of the webserver you're
running on allow it, you'd probably better use a .htaccess file in the
folder your php scripts run from (or just the htdocs folder, to have it
applied to all dirs). This file would then contain at least:

php_value   session.save_path   /full/path/to/your/own/tmp/directory

That would also solve your problem.

The other error is also indeed about output being sent before setting a
cookie. You can use ob_start() to get rid if it. But I won't do that. It
just creates overhead, makes your scripts heavier.. As you probably would
have guessed, this time the Warning rose because your script outputted some
other error message, which makes your script also output it's headers. When
you get rid of that first warning, the others will be gone too.

Let me know if it helped you !

Wouter

-Oorspronkelijk bericht-
Van: Peda [mailto:[EMAIL PROTECTED]
Verzonden: zaterdag 16 augustus 2003 23:29
Aan: [EMAIL PROTECTED]
Onderwerp: [PHP] Sessions


Hi!!

I have some problem on my site.

When I'm using this PHP script:

?php
session_start();
session_register( aUser, aAccount );
$aUser  = Cidnie;
$aAccount   = 1016;
?
html
head
 titleGetting Started With Sessions: Page 1/title
/head
body
?php
print( Current User: $aUserbr );
print( Current Account: $aAccountbr );
?
brbr
a href=listing2.phtmlGo to page 2/a
/body
/html

I'm getting this warning messages:

Warning: session_start(): open(/tmp/sess_cbd07ca5b53347ca5003404053754bde,
O_RDWR) failed: Permission denied (13) in
/home2/pena/public_html/listing1.php on line 2

Warning: session_start(): Cannot send session cookie - headers already sent
by (output started at /home2/pena/public_html/listing1.php:2) in
/home2/pena/public_html/listing1.php on line 2

Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at /home2/pena/public_html/listing1.php:2) in
/home2/pena/public_html/listing1.php on line 2

Warning: Unknown(): open(/tmp/sess_cbd07ca5b53347ca5003404053754bde, O_RDWR)
failed: Permission denied (13) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that
the current setting of session.save_path is correct (/tmp) in Unknown on
line 0


It looks like I don't have permission to write in /tmp/ directory.
Can I change that permission?

Greetings, Peda!!!



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



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



[PHP] Have I over done this?

2003-08-16 Thread John Taylor-Johnston
Have I over done this? Can I clean up this code any?
I have two states

1) Admin mode
2) Normal mode

in Normal mode, I have two states:

a) student is not in the database
a) student is in the database and has likely reloaded the browser. I'm trying to avoid 
multiple entries with the same $StudentId

 ###
 ### if $_POST[StudentId is 9995, we are in Administrative mode
 ### StudentId=9995 had already been created as id=1
 ### MySQL can only update id=1
 ###
 if($StudentId == 9995)
 {
 OpenServer();
 $sql = UPDATE $db.$table SET
  FamilyName  = '$FamilyName',
  FirstName   = '$FirstName',
  HomeFac = '$HomeFac',
  SessionSelected = '$SessionSelected'
  WHERE StudentId = '9995';
 mysql_query($sql) or die(print mysql_error());
 CloseServer();
 }else{
 ###
 ### We are in normal mode
 ###
 OpenServer();
 $sql = select StudentId from $table where StudentId = .$StudentId;
 $news = mysql_query($sql) or die(print mysql_error());
  if (mysql_num_rows($news) == 0)
  {
  ###
  ### $_POST[StudentId has never registered
  ###
  OpenServer();
  $sql = INSERT INTO $db.$table
  (StudentId,FamilyName,FirstName,HomeFac,SessionSelected)
  values ('$StudentId','$FamilyName','$FirstName','$HomeFac','$SessionSelected');
  mysql_query($sql) or die(print mysql_error());
  CloseServer();
  }else{
  ###
  ### $StudentId has registered and has likely
  ### reloaded the browser.
  ### This should prevent multiple entries with
  ### the same $StudentId
  ###
  OpenServer();
  $sql = UPDATE $db.$table SET
   FamilyName  = '$FamilyName',
   FirstName   = '$FirstName',
   HomeFac = '$HomeFac',
   SessionSelected = '$SessionSelected'
   WHERE StudentId = '$StudentId';
  mysql_query($sql) or die(print mysql_error());
  CloseServer();
  }
 CloseServer();
 }

function OpenServer()
{
global $server,$user,$pass,$db;
$myconnection = mysql_connect($server,$user,$pass);
mysql_select_db($db,$myconnection);
}

function CloseServer()
{
global $server,$user,$pass;
$myconnection = mysql_connect($server,$user,$pass);
mysql_close($myconnection);
}



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



Re: [PHP] better understanding of ereg_replace and other functions

2003-08-16 Thread Jaap van Ganswijk
At 2003-08-16 23:05 +, Curt Zirzow wrote:
* Thus wrote Binay Agarwal ([EMAIL PROTECTED]):
 Hi everybody,
 
 Lot of places in manual i came across using ereg_replace or ereg is very 
 resource intensive and hence its better to use preg_replace or str_replace or 
 strpos if they do the jobs.
 

I believe the use of ereg_replace in the samples you see is mainly
due to the fact that not until recently has preg_* function been
enabled by default. So it would make sense for the manual to use
examples with ereg_* functions so the example would be garuenteed
to work.

Plus that the ereg functions implement the old-fashioned
Unix regular expressions and preg the Perl variation.
Of course the Unix version (dating from around 1975 or
even earlier) is much more standard than the Perl version
of around 1990 (?).

I would even suggest someone to use str_replace over preg_replace.

Yes.

The fact being that anytime you call a regular expression function
it has to compile the expression and then apply that compiled
expression to the string.  Where the str_replace is directly
manipulating the  string which is quicker than preg_replace's
method.

Compiling the expression is a (time) linear
process so it doesn't matter.

The only time the overhead is acceptable would be when
you're string is not entirely known, so:

  preg_replace('foo-bar-', '', $str);

Can simply be changed to:
  
  str_replace('foo-bar-', '', $str);

The expression, however:
  preg_replace('foo-\w+-', '', $str);

Can't be done with str_replace.

As for the resouce usage vs. ereg and preg, I believe it is
entirely the nature of the libraries that they use.  I don't think
the source of the functions will reveal too much. 

The real problem is that ereg functions probably
allow more recursion to take place than preg
(which was designed long after the disadvantages
of ereg where known).

In computer science it is never considered a
problem as long as a process is (time) linear,
so that when the input is of size n, the time
taken is n times a constant factor. Just wait
18 months and the average CPU is twice as fast.

What can be a problem however is when a proces
is not (time) linear but for example quadratical
in the time needed for input of size n. So the
time to handle an input of size n is n^2 (times
a constant). This is also no problem when n is
small, but when n gets to be 100 or 1000, the
time consumption gets to be 10,000 or 1000,000
which can become problematical.

The normal str functions are generally (time)
linear in order. The ereg functions can be
recursive and therefore quadratical (or worse)
in nature and the preg functions seem to limit
this because of how they are defined.

But I'm sure that when one would compare the time
taken by the normal str functions to that of ereg
functions given the same simple regular expression
(just a string) that the ereg functions are not
more than twice as slow (and therefore of the
same order) and won't become of quadratical order.

Anyone care to try this out? Just use quite a long
string to search in and execute the search a 1000 or
1000,000 times to make it measurable. Could be a nice
school project...

Greetings,
Jaap


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



Re: [PHP] Sessions

2003-08-16 Thread Curt Zirzow
* Thus wrote Jaap van Ganswijk ([EMAIL PROTECTED]):
 At 2003-08-16 22:45 +, Curt Zirzow wrote:
 * Thus wrote Jaap van Ganswijk ([EMAIL PROTECTED]):
  At 2003-08-16 23:28 +0200, Peda wrote:
  
  When you have a shell login, try this:
  - cd /tmp
  - chown . your_user_name
  
  This probably gives an error warning.
  
  - chmod u+rw .
 
 Don't set your /tmp directoy to those settings. /tmp is a system
 directory and should not be owned by any paticular user nor have rw
 permissions for a paticular user.
 
 You're missing some points here:
 - When everything is organized okay, he can't make
   himself the owner of /tmp, so trying it doesn't
   hurt.

True, it wont hurt, but why suggest to incorrectly do something
that is most likely going to fail anyway.

 - But it isn't organized okay and he is asking how
   he can check/change it.

again, fixing it incorrectly isn't the solution.

 - It doesn't hurt when the /tmp directory is from a
   particular user as long as every one has read and
   write permission. Root and programs running with
   root-permissions can do what they want anyway.

Yes it does hurt, /tmp should only be set up to whoever created the
file can read write to it, no one else can touch the file.

 - If he would manage to own the /tmp directory,
   changing his own 'u'=user permissions don't
   affect the permissions of others, but it would
   help him to solve his problem (and isolate the
   problem in case he would want a more fundamental
   solution).

The problem is already isolated. the /tmp directory needs to have
the correct permissions.


Curt
-- 
I used to think I was indecisive, but now I'm not so sure.

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



Re: [PHP] Sessions

2003-08-16 Thread Jason Sheets
Just a note, in most cases where you have your own private /tmp it is 
not the same /tmp PHP uses.  You are in a chrooted or jailed environment 
with a virtual /tmp where usually Apache runs outside this restricted 
environment , the biggest reason being running a seperate set of Apache 
processes would be very expensive on the resources.  If you are using 
Ensim this is the way it is setup and a few other environments I know of 
do the same thing.

In this case changing your virtual /tmp ownership would not help 
Apache/PHP not being able to write to /tmp.

Jason

Curt Zirzow wrote:

The problem is already isolated. the /tmp directory needs to have
the correct permissions.
Curt



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


[PHP] [php] explode that :) !

2003-08-16 Thread John Taylor-Johnston
$P1OC1Q1 = 1¶some text or some comment;

echo trtdYour score is: /tdtd; $score=split($P1OC1Q1,¶); echo 
$score[0]./td/tr\n;

Do I have to go through all that to get score[0] ?

John


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



Re: [PHP] [php] explode that :) !

2003-08-16 Thread [EMAIL PROTECTED]
Looks like a really simple piece of code except for the cryptic variable 
names.

John Taylor-Johnston wrote:

$P1OC1Q1 = 1¶some text or some comment;

echo trtdYour score is: /tdtd; $score=split($P1OC1Q1,¶); echo $score[0]./td/tr\n;

Do I have to go through all that to get score[0] ?

John

 



--

Raditha Dissanayake
-
http://www.radinks.com/sftp/
Lean and mean Secure FTP applet with Graphical User Inteface.
just 150 Kilo Bytes


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


Re: [PHP] [php] explode that :) !

2003-08-16 Thread John Taylor-Johnston
Kind of hoping to do shorten it like this:

echo trtdYour score is: /tdtd.$score[0]=split($P1OC1Q1,¶)./td/tr\n;

No such hopes?

 Looks like a really simple piece of code except for the cryptic variable names.

 $P1OC1Q1 = 1¶some text or some comment;
 echo trtdYour score is: /tdtd; $score=split($P1OC1Q1,¶); echo 
 $score[0]./td/tr\n;
 
 Do I have to go through all that to get score[0] ?


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



Re: [PHP] [php] explode that :) !

2003-08-16 Thread Mike Migurski
echo trtdYour score is: /tdtd; $score=split($P1OC1Q1,¶); echo
$score[0]./td/tr\n;

Do I have to go through all that to get score[0] ?

I think reset(split()) should work for getting the first element.

-
michal migurski- contact info and pgp key:
sf/cahttp://mike.teczno.com/contact.html


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



RE: [PHP] [php] explode that :) !

2003-08-16 Thread Sævar Öfjörð
Why not:

echo trtdYour score is:
/tdtd.split($P1OC1Q1,)./td/tr\n;

-Original Message-
From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] 
Sent: 17. ágúst 2003 03:48
To: [EMAIL PROTECTED]
Subject: Re: [PHP] [php] explode that :) !

Kind of hoping to do shorten it like this:

echo trtdYour score is:
/tdtd.$score[0]=split($P1OC1Q1,¶)./td/tr\n;

No such hopes?

 Looks like a really simple piece of code except for the cryptic
variable names.

 $P1OC1Q1 = 1¶some text or some comment;
 echo trtdYour score is: /tdtd; $score=split($P1OC1Q1,¶);
echo $score[0]./td/tr\n;
 
 Do I have to go through all that to get score[0] ?


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



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



Re: [PHP] [php] explode that :) !

2003-08-16 Thread John Taylor-Johnston
 Why not:
 echo trtdYour score is:
 /tdtd.split($P1OC1Q1,¶)./td/tr\n;

Ok, but what happens when $P1OC1Q1 = . It errors out.

$P1OC1Q1 = ;#left blank
$P1OC1Q2 = 1¶bunch of text;
$P1OC1Q3 = 1¶bunch of text;
$P1OC1Q4 = 1¶bunch of text;
$P1OC1Q5 = 1¶bunch of text;
$P1OC1Q6 = 1¶bunch of text;




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



Re: [PHP] [php] explode that :) !

2003-08-16 Thread John Taylor-Johnston
Actually this does not work:

echo split($P1OC1Q1,¶);

There are two variables in $P1OC1Q1 = 1¶a bucnh of text
I want to split $P1OC1Q1 and get 1 as a numeral for a calculation. I was looking for 
a cleaner way to do it.

$P1OC1Q1 = 1¶some text or some comment;
echo trtdYour score is: /tdtd; $score=split($P1OC1Q1,¶);
echo $score[0]./td/tr\n;

My problem becomes more difficult when $P1OC1Q1 = ;
Split errors out.


SævË Ölêöyp wrote:

 Why not:

 echo trtdYour score is:
 /tdtd.split($P1OC1Q1,)./td/tr\n;

 -Original Message-
 From: John Taylor-Johnston [mailto:[EMAIL PROTECTED]
 Sent: 17. ágúst 2003 03:48
 To: [EMAIL PROTECTED]
 Subject: Re: [PHP] [php] explode that :) !

 Kind of hoping to do shorten it like this:

 echo trtdYour score is:
 /tdtd.$score[0]=split($P1OC1Q1,¶)./td/tr\n;

 No such hopes?

  Looks like a really simple piece of code except for the cryptic
 variable names.
 
  $P1OC1Q1 = 1¶some text or some comment;
  echo trtdYour score is: /tdtd; $score=split($P1OC1Q1,¶);
 echo $score[0]./td/tr\n;
  
  Do I have to go through all that to get score[0] ?

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

--
John Taylor-Johnston
-
If it's not open-source, it's Murphy's Law.

  ' ' '   Collège de Sherbrooke:
 ô¿ô   http://www.collegesherbrooke.qc.ca/languesmodernes/
   - Université de Sherbrooke:
  http://compcanlit.ca/
  819-569-2064



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



[PHP] substr ?

2003-08-16 Thread John Taylor-Johnston
How can I find out if $mystring includes the character ¶?
Thought substr would do it?
J


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