101

Re: PHP - всі за і проти

https://v1.std3.ru/71/b7/1450110575-71b77b2bd06f431f2bd0b4abb983738f.gif
як я бачу ситуацію цієї теми

Подякували: 221VOLT1

102 Востаннє редагувалося Sensetivity (15.12.2015 20:09:27)

Re: PHP - всі за і проти

Invader написав:

Detail in error messages


PHP does a terrible job of providing detail in error messages. For example:

$ cat quotes.php
<?php

$string = "welcome to my personal home page;

# a fake example; just imagine some lenghty code here
if ($page_id == 0) {
  render_home_page();
} elsif ($page_id == 1) {
  render_contacts_page();
} elsif ($page_id == 2) {
  render_about_page();
} elsif ($page_id == 3) {
  render_services_page();
} elsif ($page_id == 4) {
  render_weather_page();
} elsif ($page_id == 5) {
  render_news_page();
}

print "thank you for visiting!";


$ php quotes.php

Parse error: syntax error, unexpected T_STRING in quotes.php on line 20

PHP identifies the issue on line 20, while the real mistake is on line 3. In contrast, here's what Perl does in the same situation:

$ perl quotes.pl
Bareword found where operator expected at quotes.pl line 20, near "print "thank"
  (Might be a runaway multi-line "" string starting on line 3)
        (Do you need to predeclare print?)
Unquoted string "visiting" may clash with future reserved word at quotes.pl line 20.
syntax error at quotes.pl line 20, near "print "thank you "
Can't find string terminator '"' anywhere before EOF at quotes.pl line 20.

Note especially that second line not only points the developer to the correct location, but also describes exactly what it thinks is happening.

Рядок №20 це там де print "thank you for visiting!";

DEL

103 Востаннє редагувалося Invader (15.12.2015 20:13:56)

Re: PHP - всі за і проти

reverse2500, C краще за всіх?

104

Re: PHP - всі за і проти

Invader написав:

reverse2500, C краще за всіх?

О так! :)