1

hello i have problem with my project

public function toUpper($plain){
        $upper = strtoupper($plain);
        $pos = strpos($plain,$upper);
        $length = strlen($plain,$upper);
        if($pos !== false && $pos == 0){
            return $upper.substr($plain, $length);
        }else{
            return $upper.$plain;
        }
    }

and my problem on

$upper = strtoupper($plain);

please help me, thank you

  • Is this in a class? – Rwd Jun 02 '18 at 09:32
  • "_Parse error: syntax error, unexpected 'public' (T_PUBLIC)_" says your problem is (probably) in `public function toUpper($plain){`, not in your `strtoupper()` code. If it's in a class, post the code that comes beforehand, if not in a class, remove `public` – brombeer Jun 02 '18 at 09:32
  • 1
    Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Nigel Ren Jun 02 '18 at 09:35
  • that function on a `class LayoutController extends BaseController {` with many function , before this function also already there is `$ plain`, but no error, my goal to convert my data into all capital letters, `$ plain = column name` – Wahyuni Islammia Jun 02 '18 at 09:37
  • Also - `strlen()` only has one parameter. – Nigel Ren Jun 02 '18 at 09:38
  • I just tried it and the error remains the same – Wahyuni Islammia Jun 02 '18 at 09:47
  • Can you post the class please? There's probably an error before that code – brombeer Jun 02 '18 at 09:56
  • `class LayoutController extends BaseController {` that is the class , and i can't copy all because many function on that class – Wahyuni Islammia Jun 02 '18 at 10:15
  • Well then. Using an IDE and proper formatting might help you. – brombeer Jun 02 '18 at 10:39

2 Answers2

0

The visibility of a function may only be specified for functions within a class. Either remove the public keyword to define a function outside of a class or move this code within a class definition.

jspcal
  • 50,847
  • 7
  • 72
  • 76
0

remove public if this function in not with in the Class If in class please check for missing ";"

Pop Here
  • 34
  • 1