Talk:PHP/Archive 8

Latest comment: 9 months ago by 131.200.248.40 in topic throws keyword
Archive 5Archive 6Archive 7Archive 8

Criticism of PHP

It seems odd that there is no Criticism section in this article. I suppose Security does touches on some points, however. Brightgalrs (/braɪtˈɡæl.ərˌɛs/)[1] 15:06, 20 November 2015 (UTC)

Probable misleading statement.

Current text states as flat fact a 100% performance improvement. I'm dubious of this unless it's plain php5 without the op code optimization. Lycurgus (talk) 17:53, 6 December 2015 (UTC)

php4-style constructors were NOT removed in php7, merely E_DEPRECATED

quote "Support for legacy PHP 4-style constructor methods was removed[48]", that's wrong, it's still present. the plan is that in the future, only __construct will be used, and the classname will also be a valid, normal, function member. as of php7 (and at least up to 7.0.4), if it encounters a class with only php4-style constructor, it will throw an E_DEPRECATED error with the message "Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; c has a deprecated constructor", but still use the constructor. if it encounters a class with both php5-style AND php4-style constructors, only the __construct will be used. Divinity76 (talk) 07:24, 17 March 2016 (UTC)

Syntax highlighting

@Kbrose: has removed the syntax highlighting of the PHP and HTML code on this page. To avoid us both violating WP:3RR I'm bringing this to the talk page. I think that the syntax highlighting is useful: it makes different tokens visually distinct, so it is clearer to the reader what the boundary between parts of source code is. It also shows which tokens are in the same family: similar tokens share the same styling. So I disagree with their assertion that syntax highlighting is useless without a legend, indeed I don't think I've ever seen syntax highlighting done with a legend. The other argument I would have is that other programming language articles also use syntax highlighting, e.g. Pascal and Haskell. Finally, I don't see what harm highlighting causes. Removing it will make things harder to parse for some people and have no effect on others. But it wasn't harming anyone, so why remove it? It being "useless" is not a sufficient reason. —ajf (talk) 01:33, 18 November 2015 (UTC)

I have yet to find an article on WP where highlighting is useful, as most usages only present very short snippets of code without context. The average reader has no concept of what is being highlighted, and an experienced programmer doesn't need it here. In most cases the highlighting is confusing, because invariably the items highlighted are not what is being discussed or intended to be illustrated in the text. The example of inclusion of a PHP code line in HTML is only one obvious example of wrong highlighting, what should be highlighted is the PHP line, not something else, such as the PHP constants in the code.
The argument that "if it doesn't harm" anything it may be included is nonsense. Only features proven useful should be included, what is useless and only clutters the article should indeed be removed. This is a general purpose encyclopedia, not a medium to satisfy some specialists' idea of presenting syntax. This is not a programming editor. This is only common sense. Kbrose (talk) 01:47, 18 November 2015 (UTC)
In general, I'd say that syntax highlighting is useful. — Dsimic (talk | contribs) 00:47, 4 January 2016 (UTC)
Ditto. II | (t - c) 15:26, 16 April 2016 (UTC)

Remove Hello World

Some years ago now I added the <?= 'Hello World'; to the syntax section. I think both this, and the "HTML" version should be removed. They're both unhelpful and misleading (the HTML one more so).

We should avoid focusing on PHP's use as a templating engine. While it was designed for exactly this, these days it's the last thing you should use it for.

Additionally, the part on PHP's delimiters is incorrect: there is no need to use ?> if there is nothing after the PHP, and it is recommended not to. — Preceding unsigned comment added by Gisleburt (talkcontribs) 21:44, 2 May 2016 (UTC)

Hm, I'm not sure that not using ?> is actually recommended? — Dsimic (talk | contribs) 02:31, 31 May 2016 (UTC)
It is: http://php.net/manual/en/language.basic-syntax.phptags.php "If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script." — Preceding unsigned comment added by Bbio1092 (talkcontribs) 21:52, 14 July 2016 (UTC)

Hello fellow Wikipedians,

I have just added archive links to one external link on PHP. Please take a moment to review my edit. You may add {{cbignore}} after the link to keep me from modifying it, if I keep adding bad data, but formatting bugs should be reported instead. Alternatively, you can add {{nobots|deny=InternetArchiveBot}} to keep me off the page altogether, but should be used as a last resort. I made the following changes:

When you have finished reviewing my changes, please set the checked parameter below to true or failed to let others know (documentation at {{Sourcecheck}}).

 Y An editor has reviewed this edit and fixed any errors that were found.

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

Cheers.—cyberbot IITalk to my owner:Online 03:13, 31 March 2016 (UTC)

The reference was later replaced with a better one. 80.221.159.67 (talk) 07:56, 17 August 2016 (UTC)

WikiProject PHP

-- 1Wiki8........................... (talk) 17:55, 2 September 2016 (UTC)

Hello fellow Wikipedians,

I have just modified 2 external links on PHP. Please take a moment to review my edit. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit this simple FaQ for additional information. I made the following changes:

When you have finished reviewing my changes, you may follow the instructions on the template below to fix any issues with the URLs.

 Y An editor has reviewed this edit and fixed any errors that were found.

  • If you have discovered URLs which were erroneously considered dead by the bot, you can report them with this tool.
  • If you found an error with any archives or the URLs themselves, you can fix them with this tool.

Cheers.—InternetArchiveBot (Report bug) 18:18, 14 September 2017 (UTC)

Low quality and biased tone

The ‘Criticism’ section is written in very low-quality English and the tone is pretty biased against the criticism it’s reporting. Martenjacobs (talk) 14:38, 18 November 2017 (UTC)

PHP's member visibility features harmful?

'PHP's member visibility features have sometimes been described as "highly useful."[1] However, they have also sometimes been described as "at best irrelevant and at worst positively harmful."[2]'

The referenced article with the "positively harmful" opinion has no credited author. I have no issue with criticism of PHP appearing in this article, but it should come from a non-anonymous, reputable source and not just be a rant, which is what the referenced article appears to be. I suggest removing the sentence, and optionally for balance, finding an credible article from a respected author to quote instead, or removing the positive statement as well. Danielklein (talk) 04:31, 30 April 2018 (UTC)

Agreed: I've gone ahead and removed both sentences, because even if these sources were reputable, they're not saying anything particularly noteworthy. The anti-modifier rant, in particular, isn't really about PHP at all, but about the principle of member visibility which was around for decades before PHP incorporated it (although the author doesn't seem to realise this).
If there were a reputable or frequently-cited source discussing some problem with *the specifics of visibility as implemented in PHP*, that might be relevant to include; but these weren't. - IMSoP (talk) 20:32, 22 June 2018 (UTC)

References

  1. ^ Gervasio, Alejandro. "More on Private Methods with PHP 5 Member Visibility". devshed.com. Retrieved 24 November 2010.
  2. ^ "Visibility in PHP: Public, Private and Protected". aperiplus.sourceforge.net. Retrieved 2010-08-26.

But vs. and

   The words "but" and "and" each join two assertions; for "but" to be applicable depends pretty much on the first assertion being obsoleted by the second. The notion that the originally intended meaning disappeared into a time warp or some other form of "singularity" is a cute affectation, but for our purposes, the, uh, origin story is part of the encyclopedic topic, and the cuteness achieved by "but" is not just free of encyclopedic significance but also a harmful distraction.
--Jerzyt 05:47, 31 October 2018 (UTC)

PHP object section uses php 7.4 syntax

In the PHP object section the code examples are using typed properties. This isn't yet released and will throw an error in current version of php. A bit confusing to have it in the example section.

public string $name;

should be:

public $name; — Preceding unsigned comment added by 158.174.24.242 (talk) 15:00, 13 June 2019 (UTC)

Making the intro more comprehensable especially when people are reading on other wikipedia articles where PHP is mentioned and they need a quick understanding by invoking the intro

Here's my rewrite; let me know what you think:

PHP: originally stood for "Personal Homepage Page" and came out of Rasmus Lerdorf's need to make a static webpage more dynamic, i.e. interacting with the visitor of the page. Rasmus did so by making the server's programming language "call" little scripts he wrote that would invoke interaction with the user and thus make static webpage more dynamic. Later on these scripts evolved to a programming language where the PHP acronym was held and now is mostly remembered as PHP - a general-purpose Programming language for Hypertext Preprocessing.

PHP was originally created by Rasmus Lerdorf in 1994;[6] the PHP reference implementation is now produced by The PHP Group.[7] PHP originally stood for Personal Home Page,[6] but it now stands for the recursive initialism PHP: Hypertext Preprocessor.[8]

Sincerely,--SvenAERTS (talk) 10:58, 28 November 2019 (UTC)

In my opinion that would work as the intro of a textbook chapter on PHP, but not quite as an encyclopedic intro since it goes into the history rather than the current status. I agree we could make the intro a little bit more helpful for the layman reader, it would for example be good to mention how ubiquitous it is/was for web servers and that sites such as Wikipedia, Wordpress and previously Facebook were written in it (although it would probably be undue weight, even if helpful). – Thjarkur (talk) 15:23, 28 November 2019 (UTC)
I don't think the suggested rewrite would agree with the Manual of Style, particularly MOS:FIRST. I also share Thjarkur's concerns regarding the weight given the early history. Huon (talk) 19:20, 28 November 2019 (UTC)

Should we match the PHP: Supported Versions designations

Rather than "Old version", "Older version, still maintained" & "Latest version", https://www.php.net/supported-versions.php uses "End of life", "Security fixes only", & "Active support". Should we endeavor to match that? It might be useful to users to know what is deprecated & what is only receiving security fixes. Peaceray (talk) 18:51, 6 February 2020 (UTC)

Bad grammar, confusing sentence

"As of April 2020, over half of sites on the web using PHP are still on discontinued/"EOLed"[13] version 5.6 or older;[14] and with version 7.0 and 7.1 over 68%, that are neither officially supported by The PHP Development Team,[15] while security support is provided by third parties,..." -- what does this mean? Grammar is wrong. 2A00:23C5:FE0C:2100:B576:B877:BD5D:BEF5 (talk) 17:47, 15 May 2020 (UTC)

Talk

I want to know if I can talk with any one here Lunathi Gxekwa (talk) 21:55, 30 June 2020 (UTC)

Only if it is relevant to improving the article. IdreamofJeanie (talk) 22:37, 30 June 2020 (UTC)

Not even Debian knows why they're mentioned

No, seriously, is there any relevance to stating that "that not even Debian supports" PHP 5.6 or older?

Is there some common knowledge I'm missing, like Debian having a reputation for supporting very old software? Perhaps this is true, but I don't think it is obvious to the average person or programmer.
(Is the point is to emphasize how unsupported PHP 5.6 & below are?)

Either way, the additional side-note that "(while Debian 9 still supports version 7.0 and 7.1, those versions are however already discontinued by The PHP Development Team)" seems wholly unnecessary & off-topic, and (IMHO) it should be removed.

~ 2600:1700:1261:E730:D4EB:3BD7:B0E:F1D7 (talk) 06:24, 20 September 2020 (UTC)

Template error in infobox

I don't know where to put this as so many different systems are affected, but I assume many watchers of this article are familiar with code going wrong... currently the infobox has an error "Error: first parameter cannot be parsed as a date or time." The error comes from the code {{start date and age|{{wikidata|qualifier|P348|P577}}}}. The inner template returns "29 October 2020; 29 October 2020" because apparently it fetches the date both from the latest stable release and the release candidate version. That's not a valid date for the outer template, so we get this error. Is this a more general problem of the wikidata template? Is it expected to return multiple dates? If yes, can we avoid this problem by changing the Wikidata entry? If not, what else can we do to fix the error? We can put the date into the article manually, of course, but that's not a proper fix of the issue. Fetching the version ({{wikidata|property|reference|P348}}) works flawlessly. User:Romainluc last changed the Wikidata entry. --mfb (talk) 21:32, 14 November 2020 (UTC)

Try WP:VPTGhostInTheMachine talk to me 22:11, 14 November 2020 (UTC)
@Mfb: I added |single= to that line of the infobox as a temporary work-around until the underlying problem is identified and solved. I'm not sure what will happen if there is a release candidate that is dated AFTER the date of the last stable release - it might return the wrong date. davidwr/(talk)/(contribs) 23:47, 14 November 2020 (UTC)
Infoboxes should be using Module:WikidataIB. – Jonesey95 (talk) 01:08, 15 November 2020 (UTC)

It's December

It's past 26 November so shouldn't it be in the past tense? by kaiete (talk) 20:25, 2 December 2020 (UTC)

Syntax highlighting

The syntaxhighlight tag does not support modern PHP syntax:

$person = new class
{
    public $firstName = "John";
    public $lastName = "Smith";

    public function name(){
        return "$this->firstName $this->lastName";
    }
};

or

class MyClass
{
    public string $var1;

    public array $var2;

    function pr(string|int $array, array|null $subj): float|false
    {

    }
}

$myObj->pr(subj: [1, 2], array: "John");

37.212.37.47 (talk) 17:10, 25 January 2021 (UTC)

Dropping legacy file extensions

The infobox currently has this for file extensions:

php, phtml, php3, php4, php5, php7, phps, php-s, pht, phar

Some of these are extremely rare to see in the wild, like php3. I am wondering if it would make sense to drop these from the infobox, so we are left with just the common ones (roughly sorted by how common):

php, phar, phps, phtml

And then perhaps we have a line somewhere in the article that explains why you might come across something like .php3 in a legacy system? Modern PHP just does not have all these silly extensions.

Ancarda (talk) 09:13, 3 May 2021 (UTC)

SampleCode replaces Screenshot in this type of Infobox

@Ancarda: Hi, SampleCode argument is new and it should be used is instead of the past argument "screenshot". See, SampleCode has an abstract description of the total programming style. It conveys important information about remaining parts of this Infobox. So we should use this argument as the second rendering item, to successfully convey an overview of PHP language. Thanks, Hooman Mallahzadeh (talk) 12:22, 3 February 2022 (UTC)

Dear @Peterl: Please read the above paragraph. By the same reason, perhaps we should apply that for Java and Javascript. If you disagree, please discuss that here. Thanks, Hooman Mallahzadeh (talk) 17:55, 3 February 2022 (UTC)

@Hooman Mallahzadeh:. Interesting, it seems some languages have sample code in a screenshot, I wasn't aware of that. I had a look through the Wayback Machine and it seems the PHP article never did. Nevertheless, the article has many code snippets, e.g. https://en.wiki.x.io/wiki/PHP#Example demonstrates OOP, string concatenation, list usage ([], foreach), closures & functional programming (array_walk), string interpolation, and one style of comments (//).

I appreciate the infobox might support a snippet to give a feel of the language, but just having hello world there doesn't seem useful to me. Perhaps it's useful to other people, I'm not sure. I especially feel this as https://en.wiki.x.io/wiki/PHP#Syntax gives two different ways to accomplish hello world. I honestly think a screenshot is fine -- is that deprecated for accessibility reasons? It seems like you'd have to put a lot of text there to make it useful (which you can't fit into the infobox), or somehow make it expand (like an image does today when you click on it).

Do a lot of other languages have this? I will admit I reverted your edit because I had seen previous similar edits reverted too, e.g. https://en.wiki.x.io/w/index.php?title=JavaScript&diff=next&oldid=1069635829&diffmode=source Ancarda (talk) 05:47, 5 February 2022 (UTC)

@Ancarda: I have a question: What comes at the first glance in your mind when you hear the word "PHP"? For myself at the first glance is a small program like "Hello world", that is a typical instance of the total concept of programming language PHP. What about you? Hooman Mallahzadeh (talk) 06:34, 5 February 2022 (UTC)
@Ancarda: Or a better guestion: How you would explain the concept of PHP language to a bachelor student at his first term? Perhaps you would use a simple example, and not explain items like "Paradigm", "type discipline", and others. OK? Here we use "Hello World" program at Infobox to introduce PHP for a person who does not have any skill in programming. Hooman Mallahzadeh (talk) 06:40, 5 February 2022 (UTC)

@Hooman Mallahzadeh:

For myself at the first glance is a small program like "Hello world", that is a typical instance of the total concept of programming language PHP

I'm not sure what you mean by total concept. Printing something to the console doesn't seem to demonstrate enough differences between programming languages. Just from hello world, what differences can you see between these two languages:

print("hello world")
main = putStrLn "hello world"

It looks like you can just substitute some function calls print -> putStrLn and change the syntax slightly (i.e. drop parens) to translate Python into Haskell... but you can't. These snippets miss a very important fact that print has side-effects and putStrLn actually returns an IO (), i.e. it's monadic. It also misses the fact Python is primarily a scripting language, and so many programs will use __name__ so the programs functions can be included without executing. PHP works this way too; code outside functions will execute immediately.

If we want to give a "feel" for what these languages are like, we could expand the example, which will surface many of the differences:

import sys

def main():
    print("Type something to have it printed back")
    for line in sys.stdin:
        print(line, end = "")

if __name__ == "__main__":
    main()

vs.

printInput :: IO ()
printInput = getLine >>= (\x -> putStrLn x) >> printInput

main :: IO ()
main =
  putStrLn "Type something to have it printed back" >>
  printInput

Do you see how different the languages look just by doing something slightly more complicated than printing a fixed string to standard out? The issue I have is these snippets are now too large to put in the infobox -- again, my question is why we're replacing the screenshot with a snippet. It seems like a step back to me. If it was discussed and established somewhere, then please let me know (i.e. link me to the decision). If not (i.e. this is your proposal), I really don't see the value. Sorry.

Here we use "Hello World" program at Infobox to introduce PHP for a person who does not have any skill in programming

I've always had the impression Wikipedia is a reference for people who already know quite a bit about the topic they are reading up on, i.e. Wikipedia is not the place to go for an introduction to a topic. Perhaps I'm mistaken. Ancarda (talk) 11:37, 5 February 2022 (UTC)

Security

Graphics processing is a rapidly developing field, so what was 'current' even only recently could be outdated very quickly. Additionally, describing GPU capability by monetary cost isn't particularly descriptive, even if one assumes USD pricing. — Preceding unsigned comment added by 27.96.195.4 (talk) 04:19, 27 March 2023 (UTC)

throws keyword

The example of the throws keyword does not include the throws keyword in it. Is this even a real keyword? The docs at php.net have nothing about it. 131.200.248.40 (talk) 18:33, 4 January 2024 (UTC)

Using Type Declaration instead of Type Hints

As my change has been reverted it seems appropriate to discuss the matter.

The PHP documentations refers to them as Type declaration, see: https://www.php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration, and the original RFC introducing scalar types, uses the word "declaration", see: https://wiki.php.net/rfc/scalar_type_hints_v5 Although it is true that the PHP 5 documentation referred to them as "hints", and that the "Object Typehint" RFC is named as such but for all intent and purposes it is a type declaration.

Moreover, the word "declaration" is used in other places correctly instead of "hint", see:

PHP 7 also included new language features. Most notably, it introduces return type declarations for functions[67] which complement the existing parameter type declarations, and support for the scalar types (integer, float, string, and boolean) in parameter and return type declarations.[68]

Unusually for a dynamically typed language, PHP supports type declarations on function parameters, which are enforced at runtime. This has been supported for classes and interfaces since PHP 5.0, for arrays since PHP 5.1, for "callables" since PHP 5.4, and scalar (integer, float, string and boolean) types since PHP 7.0.[68] PHP 7.0 also has type declarations for function return types, expressed by placing the type name after the list of parameters, preceded by a colon.[67] For example, the getAdder function from the earlier example could be annotated with types like so in PHP 7:

By default, scalar type declarations follow weak typing principles.

(Emphasis mine)

As I'm new to contributing to Wikipedia, I don't know what to do about the following comment from the revert commit

"typehint" [...] is the commonly used term in the community.

As sure it is referred to that but it is not accurate, and my understanding is that Wikipedia articles should be accurate.

Can someone more experienced clarify?