Search code examples
phpstringstring-concatenation

Concatenation of strings in PHP


I'm having a folder path which I need to concatenate with subfolder which is being stored in variable for ex:

I've a path somepath\theme now I want to add theme named in the folder something like this somepath\theme\themeone I've this themeone stored in variable and trying to concatenate

$themename = 'themeone';
$path = 'somepath\theme\' . $themename;

I'm getting an error unexpected end of file.


Solution

  • Look at the syntax highlighting. You're last slash is escaping the apostrophe causing your string to not terminate. As a result you are left with an open string. You need to escape that backslash.

    $themename = 'themeone';
    $path = 'somepath\\theme\\' . $themename;