default keyword in php

256

what does the keyworddefault in php do? there's no documentation on http://php.net/default, but i get an error when using it as a function name: »unexpected T_DEFAULT, expecting T_STRING«

what does it do/where can i find information about it?

316

Answer

Solution:

default is part of theswitch statement:

switch ($cond) {
  case 1:
    echo '$cond==1';
    break;
  case 2:
    echo '$cond==2';
    break;
  default:
    echo '$cond=="whatever"';
}
965

Answer

Solution:

Adding to others answers:

default is a PHP keyword and keywords cannot be used as function name.

When you try:

function default () {
 ....
}

PHP expects to see aT_STRING ( an identifier) after the keywordfunction but sees aT_DEFAULT and flags a parse/syntax error:

unexpected T_DEFAULT, expecting T_STRING

People are also looking for solutions to the problem: php - Zend_Auth_Adapter_DbTable UTF-8

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.