[PHP] Get list of timezones from UTC offset

2007-08-05 Thread Norbert Wenzel
As far as I understand it is only possible to create a DateTimeZone 
Object from a string, which describes the timezone.


On the other hand it is not possible (at least I did not find any 
possibility) to get the users tz string, it is only possible to get the 
current UTC offset. (via JavaScript or by doing some magic with the 
users IP)


I wonder if there is a possibility to get a list of possible timezones 
with a certain offset. I could extract this list from the 
timezone_abbreviations_list or check the offset for every item in the 
timezone_identifiers_list, but those solutions seem far too complicated 
and slow.


So is there a function like
 array timezone_guesses_get(int)
where int is the UTC offset in hours and array is a list of possible 
timezone names.


thanks,
Norbert

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



[PHP] Iteration through letter

2006-09-14 Thread Norbert Wenzel

Hi,

just for fun I tried the following code:

code
for($letter = 'A'; $letter = 'Z'; ++$letter) {
echo($letter . ' ');
}
/code

What surprised me was the output, which looked like this:

A B C [...] Y Z AA AB AC [...] YY YZ

I don't have any idea how these letters get printed out, so I'd 
appreciate any guesses or explanations.


thanks,
Norbert

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



[PHP] Re: Iteration through letter

2006-09-14 Thread Norbert Wenzel

Norbert Wenzel wrote:

Hi,

just for fun I tried the following code:

code
for($letter = 'A'; $letter = 'Z'; ++$letter) {
echo($letter . ' ');
}
/code

What surprised me was the output, which looked like this:

A B C [...] Y Z AA AB AC [...] YY YZ

I don't have any idea how these letters get printed out, so I'd 
appreciate any guesses or explanations.


thanks,
Norbert


Thanks for all your replies and sorry about asking a question answered 
in the manual. I was too surprised of the result, so I didn't even think 
I could find that topic in the manual. Sorry.


Norbert

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



[PHP] Built-in Interface to rewrite empty() ?

2006-09-12 Thread Norbert Wenzel

Hi,

I think I once knew a PHP5 interface, which forces a class to implement 
a function empty(). If an object $myObject implements this interface, it 
should be possible to call empty($myObject) as it seems to work with the 
interface Countable, which does the same for count().


The problem is I didn't find such an interface in any doc I found so 
far. Does anyone of you know such an interface, or did it ever exist?


thanks,
Norbert

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



[PHP] Re: Accessing data posted from a different URL

2006-03-21 Thread Norbert Wenzel

Manuel Lemos wrote:

For instance, if you use method=post because XHTML specification says
everything should be in lower case, you will have problems with some
browsers and e-mail programs that only accept POST in upper case and
fallback to GET when they find something else.


i would call that a problem of the browser, not of xhtml standards.

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



Re: [PHP] Callbacks in XML Parser

2005-12-18 Thread Norbert Wenzel

comex wrote:

xml_set_element_handler($this-xmlParser, $this-startTag,
$this-endTag);


xml_set_element_handler($this-xmlParser, array($this, 'startTag'),
array($this, 'endTag'));


i copied this from a posting about two weeks ago by Jochem Maas:

in this case there is an alterntive:

http://php.net/manual/en/function.xml-set-object.php

Norbert Wenzel wrote:

 Robert Cummings wrote:

 On Sat, 2005-12-10 at 11:25, mail wrote:

 xml_set_element_handler($parser, xml_start_element, 
xml_stop_element); //can't find function





 use array notation for object method handlers:

 xml_set_element_handler
 (
 $parser,
 array( $this, 'xml_start_element' ),
 array( $this, 'xml_stop_element' )
 );

 Cheers,
 Rob.



 Thanks,

 Norbert

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



[PHP] XML Parsing german special chars

2005-12-14 Thread Norbert Wenzel

I did some easy xml parsing on the last.fm[1] recent tracklist.
I do read in all the tracks and output them encoded with htmlentities().

A lot of german special chars like the Ä (Auml;) are transfered to 
strange followings of an A with any sort of available accent. But it 
isn't replaced by Auml;


The xml file does not contain any character encoding information, so how 
could I tell htmlentities(), there might be some character in the 
string, which might be a german special char.


I never encountered any problems when writing htmlentities('Ähre'); or 
$var = 'Ähre';

htmlentities($var);
but only if I take the strings out of the xml file.

If I output the whole xml file all characters are shown as they are 
supposed to, only if i do the encoding by htmlentities() I get those 
weird accented letters.


any suggestions how to fix this?

thanks,
Norbert

PS: code and link to the output page can be given if needed.

[1] www.last.fm

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



Re: [PHP] OO XML Parser

2005-12-11 Thread Norbert Wenzel

Robert Cummings wrote:

On Sat, 2005-12-10 at 11:25, mail wrote:


xml_set_element_handler($parser, xml_start_element, xml_stop_element); 
//can't find function



use array notation for object method handlers:

xml_set_element_handler
(
$parser,
array( $this, 'xml_start_element' ),
array( $this, 'xml_stop_element' )
);

Cheers,
Rob.


Thanks,

Norbert

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



[PHP] Re: PDF Generator

2005-12-05 Thread Norbert Wenzel

Dan Harrington wrote:

I have a TON of forms that I have to populate, can I make a PDF file using
Acrobat Professional, and then use PHP to populate those forms and have text
inserted into the pre-made text fields that I made using Acrobat?  And if
so, what is the best tool for that?  I'd prefer to do it for free, but
spending $$ is fine too. 


Thanks
Dan


Rick Lim wrote:



What is the best FREE pdf generator for PHP?


fpdf will only draw your documents, there is no way to use it with 
forms. and i don't know any way to process pdf forms in php, but i 
didn't really need it yet.


if you find any solutions, please post them.

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



[PHP] Re: PDF Generator

2005-12-04 Thread Norbert Wenzel

Rick Lim wrote:

What is the best FREE pdf generator for PHP?


i used FPDF without any problems.

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



[PHP] Re: italic, bold and underline with GD ?

2005-11-07 Thread Norbert Wenzel

David wrote:
Can we use some function with GD to make text italic, bold and/or 
underline?


http://php.net/imagettftext

I see we can change size and font, but not style

it's not possible in PHP?

Thanks in advance
David


I'm not familiar with GD, but as every good font has different versions 
for bold, italic and so on, you might use those versions with separate 
font files.


And since underlining is just a simple line (don't know how this works 
in GD, I've done this in FPDF) I would just draw a line from the 
beginning of the word to the end ... if it is possible in GD to get the 
current cursor position before and after inserting text.


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



[PHP] Re: Making functions available from another script

2005-11-07 Thread Norbert Wenzel

Richard Leclair wrote:

Hi PHP-ers,

Here's an easy one:
Q: How can I make a function available from within another php script?

Eg. B.php contains:

?php include .../fns.php ?

Which has a function fn($x);

Later on, I want to include this function in B.php somewhere.

In short:  B.php wants to use fn($x) found in A.php.

Regards,
Richie !


I'm not quite sure if I did get your question right, but you answered 
the question yourself.


include(anyfile.php); does nothing more then copy the code of 
anyfile.php to the file, in which it is called. anyfile.php is 
interpreted as HTML, so you should have your ?php brackets around the 
document.


A.php---
function foo($bar) {
//do sth
}

B.php---
include[_once](A.php);

$x = anything you like;
$whatever = foo($x);


this works if A and B are in exactly the same directory, otherwise you 
should change the path for the include call.


Did I get your question right?

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



Re: [PHP] Re: Making functions available from another script

2005-11-07 Thread Norbert Wenzel

Richard Leclair wrote:

Hi Norbert,

Thanks for your reply.  Yeah, you were almost there - it wasn't quite what I
had in mind.  I probably should have elaborated on this one.

I'm looking at building up a library of handy functions that can be included
in a current script.

Only problem is:
(let's just say for clarity that lib.php == A.php; same)..

If I declare the functions in lib.php, then B.php can include lib.php but
cannot execute any functions within B.php (that were declared in lib.php).
it keeps coming up as function undeclared.

Any more ideas/thoughts?  Or have I not gone about this correctly?


Maybe post your lib.php and B.php, but from your description I have no 
idea what might cause this problem.


For testing maybe change your lib.php to sth like this

---lib.php
codeincluded lib.php/code
?php
echo('lib.php works');

//let your code follow here

?

Norbert

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



Re: [PHP] prevent user from getting scripts outside the web folder[this better?]

2005-10-14 Thread Norbert Wenzel

Ben wrote:
My understanding is that mysql_real_escape_string will only work while 
you are connected to mysql.  Not sure if that is the case in your 
situation.


At least it requires a connection to mysql. I had an error, when using 
it without any connection opened before, that mysql_real_escape_string 
wants to connect to the DB as [EMAIL PROTECTED] without any password.


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



[PHP] Auto unzip uploaded file

2005-09-30 Thread Norbert Wenzel
I know a script (it's a webgallery) where you upload your images.zip 
with any amount of images in it. After uploading the .zip get unzipped 
and the images will be placed into the gallery.


How did they unzip (or better, how is it possible to unzip) the file 
with php? and is it possible to extract let's say .rar or any other 
common format as well?



thanks for your suggestions,
norbert

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



Re: [PHP] Auto unzip uploaded file

2005-09-30 Thread Norbert Wenzel

Jochem Maas wrote:

Norbert Wenzel wrote:

I know a script (it's a webgallery) where you upload your images.zip 
with any amount of images in it. After uploading the .zip get unzipped 
and the images will be placed into the gallery.


How did they unzip (or better, how is it possible to unzip) the file 



might I suggest you take a peek at the 'webgallery's code?
I would if i could, but they don't want't me to see their code, so I 
have to rewrite it myself.



..and read here:
http://php.net/manual/en/ref.zlib.php
http://php.net/zip
http://php.net/manual/en/ref.rar.php
http://php.net/manual/en/ref.lzf.php
http://php.net/manual/en/ref.bzip2.php

Thanks, I'll read that.
with php? and is it possible to extract let's say .rar or any other 
common format as well?



anything is possible. how much money do you have?

Let's say time is money so I guess I'm quite rich...



thanks for your suggestions,
norbert







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



Re: [PHP] Strange behaviour overriding methods in 5.0.4

2005-09-29 Thread Norbert Wenzel
I have to say thank you to you both. In fact I still don't know what 
exactly was wrong or may have caused this error (output buffering was 
off, and there was no @ in the whole file) but after a night of sleep I 
tried again before reinstalling the server and everything worked as fine 
as it should.


It's quite strange, since I was the last one in company yesterday and 
locked it myself, but maybe some tiny little imps fixed the problem by 
night.


And to dissapoint you Jochem (at least I think it was you), it is a Red 
Hat System, no Windows.


Thanks for your help and greetings from Vienna,
Norbert

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



[PHP] Re: updating forms

2005-09-29 Thread Norbert Wenzel

(hope) wrote:

i have a text area on my page.
As page is uploaded it displays certain text in it.
It has also has a text area with same text that is being displayed above 
in the page .

If user changes this text of text area  n presses submit button
the page needs to display updated text in the text area
and as well as updated text above in the page.

2ndly the text area must display text alogwith tags
e.g h1headingh1

this goes text



but above in the page these tags must like h1 /h1
mustnt be displayed instead the heading word must become of h1 format.

how can i get all tags like br h1 etc. as enterd by user
coz if i get it on next page n save it database,
the next time wen i wil dsiplay there wil be no brs .


n how to update the page n display updated text?

regards
hope


see functions htmlentities() or htmlspecialchars() to replace  with 
lt; and so on.


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



[PHP] Strange behaviour overriding methods in 5.0.4

2005-09-28 Thread Norbert Wenzel

Hi, i have a very strange example of code. Maybe you know where my
mistake could be.

I've got an index.php with a few div's and a short php code, like:
divecho $_SESSION['view']-getContent();/div

The view is in every case one of my view objects. And there's the problem.

In my specific case $_SESSION['view'] is of class NoLoggedUserView,
which of course extends View. The View class containts a few public
methods, namely

getTitle()
getHeadline()
getSelection()
getSubselection()
getContentHeadline()
getContent()
getFunctions()

The child class NoLoggedUserView contains only the
getContent()-method, which provides a login window.

But of course I still call all the other methods like getTitle() in my
index.php.

Until yesterday I encountered no problems with that, but today, if i
call $noLoggedUserView-getTitle() in the index.php i get an empty
document. No error, no warning, no notice ... nothing. The page stays
the same and doesn't change. Even the timestamp I print out to check if
there has been a change, doesn't change.

I tested a few things:
The page loads fine and without any problems, if the public method
getTitle() is written in the NoLoggedUserView and the method returns a
stupid string. If getTitle() in NoLoggedUserView looks like this
public function getTitle() {
return parent::getTitle();
}
there is the same problem as before. I get an empty page, no changes are
made.

My current version of getTitle() looks like this:
public function getTitle() {
//return 'NoLoggedTitle'; // works great
//return parent::getTitle(); // no changes are made

$classname = get_parent_class($this);
$v = new $classname();
return $v-getTitle(); // works great
}

And again, this strange thing works.

So what could cause php to act like this? Any ideas or suggestions or at
least assumptions?

Please, I really don't know where to search the mistake..

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



[PHP] Re: Strange behaviour overriding methods in 5.0.4

2005-09-28 Thread Norbert Wenzel

Norbert Wenzel wrote:

divecho $_SESSION['view']-getContent();/div

of course this echo IS in ?php ?, i just forgot here in my message

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



Re: [PHP] passing a variable with php_self

2005-09-27 Thread Norbert Wenzel

A.J. Brown wrote:

a href=?=$PHP_SELF?action=bigger?

works well too

works only if register_globals is on, doesn't it?

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



[PHP] Re: session

2005-09-20 Thread Norbert Wenzel

Roman Duriancik wrote:

?
session_start();
session_register('pocet');
$count++;
echo $count;
session_destroy();
?
a href=test.php??php echo(SID)?link/a

and when i click on link always I have in $count value 1 but I need
value 2,3,
how to do it ?


i think this is what you asked for:

if(isset($_SESSION['count'])) {
$_SESSION['count']++;
}
else {
$_SESSION['count'] = 1;
}

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



[PHP] Dynamically determine class

2005-09-14 Thread Norbert Wenzel

Hi,

I'm using PHP5 and try to do something like this:

I have a base class called 'Entry' and a child class called 
'ExtendedEntry'. I want to read all Entries to a certain topic from a 
database.


While constructing the EntryObject I would like to look if Entry is a 
simple Entry or an ExtendedEntry.  I want the new object to be an 
ExtendedEntry - if possible - and otherwise to be an Entry.


It was not possible to return the object in the __construct() function 
and it was not possible to reassign $this with code like

$this = new ExtendedEntry()
also in the __construct() function. And I tried to always generate an 
ExtendedEntry with a flag, that says it is really Extended and a 
typecast afterwards, but I wasn't able to typecast to another object by 
(Entry) $extEntry.


Any suggestions how to solve this problem without writing a 
generateEntry() function, that looks into the database and then calls 
the correct class type?


thanks in advance,
Norbert

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



Re: [PHP] Dynamically determine class

2005-09-14 Thread Norbert Wenzel

Thanks.

Norbert

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



[PHP] Re: How to force a variable to be a custom object?

2005-09-02 Thread Norbert Wenzel

Alex Gemmell wrote:
Just a quickie today: I was wondering if I can declare a Class variable 
as a certain type of object.  I'm using PHP 4 by the way.


I don't know if this works in PHP4, but I would suggest to clear this in 
your constructur. But I don't know if this is always called in PHP4.


class myClass {

var $object;

myClass() {

$this-object = new OtherObject();

}

}

This isn't really forced, since you could change $object from outside 
the class. If there is a way you should declare $object private. That's 
not stylish, but I guess it works.


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



[PHP] Re: Catching all errors and redirecting

2005-08-19 Thread Norbert Wenzel

Thomas Hochstetter wrote:

Hi again,

Is it possible to catch all parser errors (notices), and as that happens
redirecting to a 'sorry-page-not-available-at-this-moment' page, whilst
storing the error (or notice) message somewhere else (e.g. emailing it to
the developer).

thanks

Thomas


From your name I would say you are german speaking, so i would suggest 
the error_handler example from the book


Professionelle PHP 5-Programmmierung
Entwicklerleitfaden für große Webprojekte mit PHP 5
von George Schlossnagle

erschienen in der Open-Source-Library des Addison-Wesley Verlag
ISBN: 3-8273-2198-0

Examples to this book [1] can be found under [2], the example to your 
special problem would be example 3-1.


I'm sorry for writing german, but since it's a german book, i wrote all 
the facts about the book in german.


Norbert

[1] 
http://www.addison-wesley.de/main/main.asp?page=deutsch/bookdetailsproductid=83009
[2] 
http://www.awl.de/buecher/3827321980/?SID={FC2DF695-9416-4CE0-8077-877C84150EF1}


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



[PHP] [OFF: logical question] rounding in steps of 15

2005-08-18 Thread Norbert Wenzel
Excuse me, I know my question is not PHP specific, but I hope there are 
some logical and mathematical talents in here, since I've always been 
fighting with maths. ;-)


I have to provide a textfield, where workers enter their time they 
worked on a certain subject. The smallest degree should be 15 minutes, 
but the workers may enter every time, such as 357 or maybe 1:38.


Is there any better way to determine the next 15min step, than to take 
for example 38 % 15 = 8 and see whether the result is nearer to 0 or to 
15? In this case (8) 8 + 8 would be 16 so i would save 45 minutes of work.


These are just informations for calculation of upcoming projects, so I 
don't have to check any legal rules for rounding work time or something 
like this.


I think my way is quite complicated, so I hope anyone of you knows a 
better possibility to round to a certain degree.



Thanks in advance,
Norbert

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



Re: [PHP] [OFF: logical question] rounding in steps of 15

2005-08-18 Thread Norbert Wenzel

Richard Lynch wrote:

You're on your own converting 1:38 or 357 into minutes, but:

$minutes = 357;
$minutes = 15 * round($minutes / 15);
echo minutes: $minutes\n;


Thank you both. The conversion from 1:38 to 98 is no problem, but I knew 
there was a more beautiful way round to 15 minutes.


Thanks.
Norbert

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



Re: [PHP] force download

2005-08-11 Thread Norbert Wenzel

Sebastian wrote:

some of my users are complaining that when they try download media 
files (mp3, mpeg, etc) their media player opens and doesn't allow them 
to physically download the media. These are IE users, firefox seems to 
like my code, but IE refuses to download the file and plays it instead..


can anyone view my code and see how i can force media file downloads 
on IE?


We're using the PHP based 'Moodle' system and had the similar problems 
when downloading stuff in IE. On some IEs it worked, on some IE did 
nothing, though it was the same version. The only way to fix this, was 
to search for a 'IE' String, in the browser info and to show another 
page, with a stupid 'Save as...' link to IE users.


hope that works,
norbert

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



Re: [PHP] force download

2005-08-11 Thread Norbert Wenzel

Richard Lynch wrote:

Right-click is NOT universal.

Macs don't even *have* a right-click!


Doesn't Ctrl-Click do the same as a right click?

Norbert

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



Re: [PHP] display error line in object method

2005-08-11 Thread Norbert Wenzel

Richard Lynch wrote:

There may also be some fancy new way to output the whole stack of
functions called... I haven't really checked that out yet.


The function stack is printed by debug_backtrace(), isn't it? Supported 
by PHP since 4.3.0.


Norbert

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



[PHP] Re: dynamically selecting a function

2005-08-08 Thread Norbert Wenzel

Thomas wrote:

Hi there,

 

How can I do something like this: 

 


[snip - theoretical code] if( isset($step) ) echo step.$step() ) [/snip]

 


$step would be an int (I would check that before) and then I would have all
sorts of functions like step1(), step2() . etc.

 


Any ideas?

 


Thomas


What about switch / case?

switch($step) {
 case 1:
step1();
break;
 case 2:
step2();
break;
 default:
defaultStep();
break;
}

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



Re: [PHP] Re: dynamically selecting a function

2005-08-08 Thread Norbert Wenzel

Thomas wrote:

Thanks Burhan. Is there much overhead?

Norbert: that's what I am doing now, just wanted to save some code. :-)

Thomas

-Original Message-
From: Norbert Wenzel [mailto:[EMAIL PROTECTED] 
Sent: 08 August 2005 11:18 AM

To: php-general@lists.php.net
Subject: [PHP] Re: dynamically selecting a function

Thomas wrote:


Hi there,



How can I do something like this: 




[snip - theoretical code] if( isset($step) ) echo step.$step() ) [/snip]



$step would be an int (I would check that before) and then I would have


all


sorts of functions like step1(), step2() . etc.



Any ideas?



Thomas



What about switch / case?

switch($step) {
  case 1:
step1();
break;
  case 2:
step2();
break;
  default:
defaultStep();
break;
}



i thought that would be too easy ;-)

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



[PHP] Inherit Methods

2005-08-08 Thread Norbert Wenzel
Is it possible to run inherited methods in the scope of the child class? 
 In my case I have an abstract class called 'Company' and some child 
classes. There is a non abstract function in 'Company' which prints 
'$this-phoneList'. That function should be the same to all child 
classes, without rewritting it in every class.


I call the printing method via the child class like
$childObject-printPhoneList();
The call seems to be handed over to the parent class 'Company' which is 
fine. But the $this points to the phoneList of the abstract parent 
class. So the phoneList in the abstract class seems to be unset, since i 
have set the phone list in the child class.


Here's a short example, showing what I mean:

?php

abstract class AbstractClass {

private $var;

public function printVar() {
echo('var: ' . $this-var . 'br');
}

}

class ConcreteClass extends AbstractClass {

public function __construct($var) {
$this-var = $var;
}

public function printVarChild() {
echo('var (child): ' . $this-var . 'br');
}

}

$cl = new ConcreteClass(15);
$cl-printVar();
$cl-printVarChild();
?

Output is:
var:
var (child): 15


Has anyone an idea how to print the $var of the child, without copying 
the method in every child class?


thanks in advance,
Norbert

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



Re: [PHP] Inherit Methods

2005-08-08 Thread Norbert Wenzel

Jochem Maas wrote:

Norbert Wenzel wrote:

private $var;



  get rid of the 'private' here and replace it with 'protected'


too stupid. I'm sorry for my question.

thank you for opening my eyes.

norbert

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



[PHP] Re: overwrite private class members in php5?

2005-08-05 Thread Norbert Wenzel

Matthew Weier O'Phinney wrote:

* Norbert Wenzel [EMAIL PROTECTED]:


Hi, I've done something like this:

class MyClass {

  private $var;

  function __construct($value) {
$this-var = $value;
  }

  public function printVar() {
echo($this-var);
  }

}

$object = new MyClass('1');
$object-printVar(); // prints 1
$object-var = 3; // Fatal Error as expected
$object-$var = 2; // no error msg



$var is empty, so this is setting a non-existent class property to 2.



$object-printVar(); // prints 2



I got 1 when running this -- just as I would expect. Are you sure it
printed 2?

Basically, if a property is undeclared, it is assumed public, so you can
set undefined properties without issue. If defined private or protected,
the calling script will not be able to alter the value.



i did write the script out of my mind, and didn't paste it. not the best 
idea, i know.
thanks for your help, i see my mistakes very clearly. forgive a noob for 
such question.


thanks,
norbert

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



[PHP] Exceptions: function x throws Exception

2005-08-05 Thread Norbert Wenzel
If there is a class with a function, that might throw exceptions and 
does NOT catch them, may I write that like in Java?


class FooClass {

public function foo() throws Exception {

}

}

Or is there another possibility to tell a function throws an exception 
and to force the caller to handle that exception?


thanks in advance,

Norbert

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



Re: [PHP] Exceptions: function x throws Exception

2005-08-05 Thread Norbert Wenzel

Torgny Bjers wrote:

The Java way doesn't work here. The best approach would be to simply run
a try/catch/finally around the call to your function/method, and inside
the function itself you do the following:

if (...) { throw new Exception(My message.); } }


Hello Torgny,

Thanky you for your fast help.

Greetings,
Norbert

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



[PHP] overwrite private class members in php5?

2005-07-29 Thread Norbert Wenzel

Hi, I've done something like this:

class MyClass {

  private $var;

  function __construct($value) {
$this-var = $value;
  }

  public function printVar() {
echo($this-var);
  }

}

$object = new MyClass('1');
$object-printVar(); // prints 1
$object-var = 3; // Fatal Error as expected
$object-$var = 2; // no error msg
$object-printVar(); // prints 2

Hows that possible or what's the difference between
 $object-var   and
 $object-$var ?

thanks in advance for your help!
Norbert

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



[PHP] Re: overwrite private class members in php5?

2005-07-29 Thread Norbert Wenzel

Norbert Wenzel wrote:

  public function printVar() {
echo($this-var);
  }


I have to do a little correction, i wrote
$this-$var
to see the variable, otherwise i don't see
anything.

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