Message Board


Message Board > Programming > "protected" (PHP)

June 2, 2010, 14:17
Dennis
どこかにいる
2092 posts

Ok some OO-question. I'm using PHP. It's been 4 years and nearly forgot everything.

How does this "protected" work again? private is in the class, public is from everywhere. then what is protected?

i.e.

class Condom
{
public $nudity;
private $parts;
protected $dick;
}

Who can access what?

Thanks.
____________
Kwakkel
#
June 2, 2010, 23:41
Fiona
games are terrible
-9616558 posts

Private members cannot be redefined by child class definitions but protected ones can. Other than that they work the same.
____________
laffo
#
June 5, 2010, 01:03
Htbaa
Perl
368 posts

They don't work the same.

Protected members can by accessed from outside the object, only inside and within derived classes.

Private members also can't be accessed from outside the object and neither can derived classes.
____________
blog.htbaa.com
#
June 7, 2010, 11:36
Dennis
どこかにいる
2092 posts

I won't be needing protection then since I don't derrive shit.
Top of that, error handling is quite omslachtig in PHP, but i managed to do it eventually.
____________
Kwakkel
#
June 7, 2010, 20:20
Htbaa
Perl
368 posts

How is error handling cumbersome? Use exceptions. Further more you can almost catch all other errors by setting a error handler by your own.
____________
blog.htbaa.com
#
June 14, 2010, 10:22
Dennis
どこかにいる
2092 posts

I implemented it now. Thanks for replying.

Off the record:

It is cucumbersome in that way that it only catches user-defined exceptions and you have to override the standard (just display the shit) as a function with limited parameters and handle them. This makes sure the "require <file>" is not working anymore (it simply doesn't execute in case of a grave error, even a parse error). The solution is not to use "require" at all and use OO-design in every possible way. But if a program already exists it is often not the best solution to convert the whole system to an OO-design. Time = money.


No, PHP is not my friend anymore, it crashes if it becomes too big, it can't handle threads to solve this, and it is awesomely slow unless you install alterative caching packages and stuff. It doesn't support namespaces, but it DOES support Object Oriented design. I'm kinda familiar with the "i" format for minutes by now, but what's wrong with "MI" like... ALL(?) other langauges.

A good thing is, that it is widely supported and billions of people use it.

in dutch I'd say: PHP is huis-, tuin- en keukensoftware.
____________
Kwakkel
#
June 14, 2010, 13:31
Dennis
どこかにいる
2092 posts

My apologies! It seems PHP can even read! :O

PHP code:
<?php
        $a = 'zero';
        $b = 0;
 
        if ($a == $b)
        {
                echo "PHP outsmarts you with its linguistic skills ;)";
        }
        else
        {
                echo "PHP is just like any other language";
        }
?>

____________
Kwakkel
#
June 14, 2010, 22:16
Htbaa
Perl
368 posts

That's why === is better.

I hate PHP with a passion. Even with caching, such as XCache, it's fucking slow. In a general Zend Framework MVC app a request can simply take up to 500ms without doing much. That's just too much...

PHP does support namespaces, but only since PHP 5.3. Any sane language defines namespaces like this: my.special.space or My::Special::Space. But not PHP, no, they use my/special/space. Yay for readability! And they say Perl is horrible? Morons.

Development on PHP 6 has been halted because they can't get their crap together with Unicode. I'm not saying I could do it, but it's a bit strange they just halt development because they bump into an obstacle.

When possible I try to use Perl and am planning on doing new projects at work in Perl as well. Ah yes, the wonderful world of Perl. It has Moose, Template-Toolkit, Dancer, Catalyst, Plack/PSGI, DBIx::Class and so much more. Perl makes me happy.
____________
blog.htbaa.com
#
June 17, 2010, 10:44
Zosma
Senior Procrastinator
99 posts

What is the problem with a different token for the namespaces? I really fail to see why a 'sane' language uses a dot or double semicolon, and PHP is suddenly moronic for using a slash. What does it matter.

I mean, there are some good arguments against PHP, but I don't think this one is.
____________
Fuck a duck
#
June 17, 2010, 12:57
Dennis
どこかにいる
2092 posts

PHP is all about context. If you use PHP for the wrong doeleinden you end up in a mess.

Websites? Dynamic websites? Awesome!

Logging and data transfers at night for a production db? Hell no...

I don't even get why they go Object-Oriented with it, it's not made for OOP.
____________
Kwakkel
#
June 20, 2010, 18:56
Htbaa
Perl
368 posts

Readability Zosma. Slashes don't really help with that. Lots of languages support namespaces and do it either through dots or double semicolons. None of them uses slashes.

This just doesn't seem right:
Code:
$object = new some\piece\of\shit();

http://php.net/manual/en/langu … s.rationale.php

[Edited on June 20, 2010 by Htbaa]
____________
blog.htbaa.com
#
July 6, 2010, 13:06
Dennis
どこかにいる
2092 posts

I wonder why they just don't use arrows like accessing object methods and fields.

$object = new mammals->humans->faeces->shit();
____________
Kwakkel
#
July 7, 2010, 21:10
joebeard
Bearded
9 posts

Because arrows aren't much easier to read, and also -> is used to access members of objects referenced by a pointer e.g.

SomeClass a*;

...

a->someMemberFunction(...);

I personally prefer using . because I tend to code in actionscript mostly at work and so it's grown on me... like a discussing puss filled wart.
____________
Enjoying a lovely evening with Sander Cohen
#
July 16, 2010, 12:50
Dennis
どこかにいる
2092 posts

I prefer "." too, php doesn't.
____________
Kwakkel
#
July 18, 2010, 17:28
Htbaa
Perl
368 posts

PHP depresses me. I've ranted a bit about it too: http://blog.htbaa.com/programm … ences-your-mood
____________
blog.htbaa.com
#
July 22, 2010, 09:44
Dennis
どこかにいる
2092 posts

-_-

I'm not fond of PHP myself either, however if you like to embed HTML, and to make common or garden applications with even a small database, it's not a bad choice, but don't try to analyse a production back-end system with PHP. You should be amputated of your arms if you even think about it.

One of the worst things about PHP is upgrading your shit shows you 2003898 warnings like: "OMFG the SHIT u using is nao deprecated!!!11ONEONE" on your FUCKING screen by default.
____________
Kwakkel
#
July 25, 2010, 01:06
Htbaa
Perl
368 posts

Even more funnier, they've released the latest 5.2 update and suddenly announced an instant end-of-life for the 5.2 series.

Of course, I've ranted about it: http://blog.htbaa.com/programm … get-excited-yet
____________
blog.htbaa.com
#
September 5, 2010, 19:46
Fiona
games are terrible
-9616558 posts

There are no reasons to use PHP.
____________
laffo
#
October 13, 2010, 09:43
Dennis
どこかにいる
2092 posts

Reasons to use PHP:

- Everything else fails
- You're bored to the death
- You are forced to by someone
- You simply do not know better
- It has most hits in Google
____________
Kwakkel
#

Message Board > Programming > "protected" (PHP)

Quick reply


You must log in or register to post.
Copyright © 2005 Booleansoup.com
Questions? Comments? Bug reports? Contact us!