A
A
Anton2016-11-14 23:27:57
PHP
Anton, 2016-11-14 23:27:57

PHP functional language or object oriented?

I was asked this question during an interview. How was this language originally conceived?

Answer the question

In order to leave comments, you need to log in

8 answer(s)
O
OnYourLips, 2016-11-14
@OnYourLips

How was this language originally conceived?
template engine. Not functional and not OO.
Support for these methodologies at the syntax level came later.

X
xmoonlight, 2016-11-14
@xmoonlight

I would answer like this: "What does this have to do with it?! Does the performance and architecture of the future code depend on this information? - No."
Well, here's a quote:

Thus, by choosing PHP, you get the freedom to choose the operating system and web server. Moreover, you have a choice between using procedural or object-oriented programming (OOP), or a combination of both.
He says that he is universal and is not divided.
And it was conceived as a hypertext processor for dynamic processing and creation of HTML pages (content, markup, etc.).

G
Grigory Esin, 2016-11-15
@xotey83

PHP is any language, but definitely not a functional one.
Z.Y.
It is a pity that it is impossible to write here in which particular office this was asked.
UPD
Maybe the question meant not "functional", but "procedural"? You won't believe how many people confuse procedural and functional languages.
If so, then PHP is both. More specifically, I think the correct answer in your case would be that PHP is a multi-paradigm language.

S
Sergey, 2016-11-19
Protko @Fesor

I can only give you my answer to the interviewer:
None. A distinctive feature of PHP is that it was not conceived as a programming language. This is even reflected in the name - PHP (recursive acronym for PHP: Hypertext Preprocessor).
At the PHP3 stage, it was already a full-fledged procedural programming language , where it was no longer possible to write logic in C.
In PHP4, "classes" were introduced into the language to give a state isolation mechanism. It still could not be called OOP simply because ... these are not objects but classes. There is no encapsulation, only ad-hoc polymorphism (which all languages ​​with a dynamic type system have) and limited subtype polymorphism. Well, class inheritance is already recognized as an unnecessary thing in the context of OOP.
Interfaces were finally introduced in PHP5, and it was now possible to do normal polymorphism. Access modifiers have been introduced, etc. but the language is still procedural by and large (and that's fine, since all existing OO languages ​​are procedural).
PHP5.3 introduced anonymous functions. but without lexical scopes, without higher-order functions, doing "pure functionality" simply won't work. In any case, it will be inconvenient.
From this we conclude - PHP today is a procedural programming language that has enough opportunities to practice all the main programming paradigms just with varying degrees of convenience.

S
Sergei Nazarenko, 2016-11-15
@nazares

https://ru.wikipedia.org/wiki/PHP#.D0.98.D1.81.D1....

M
Mercury13, 2016-11-15
@Mercury13

PHP was originally conceived as a scripting language - a procedural programming language with dynamic typing and the ability to enter a couple of lines without shaping the body. So it remains to this day, interspersed with OO. There is some functionality, of course, but this does not make PHP - like Java or C ++, by the way - a real functional language.

A
Anton, 2016-11-15
@Pur1taN

I thought it all depends on the task. There is both OOP and functional application. That's when the question "how did he think?" and put me in a rut.
Thanks for answers.

M
Maxim, 2016-11-15
@khrisanfov

Initially functional, then became with OOP support. In C++, too, both approaches can be used due to the legacy of C.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question