Space before and after period...

Ask about general coding issues or problems here.

Moderators: gesf, Michalio

Post Reply
User avatar
NorseMan
php-forum Active User
php-forum Active User
Posts: 44
Joined: Mon Jul 04, 2022 5:25 pm
Location: Near Oslo (Norway)

I think i got some trouble with the code pasted below:

include __DIR__.'/../Templates/' .$templateFileName;

Is it correct with a space before and after the period or not?
I have pasted an example without space.
________________
Leon (Norway)
________________

-------
(some of)My configuration is:
Laragon full 5.0 web server with PHP and MySQL installation
(Apache 2.4.47 / PHP 7.4.19 / MySQL 5.7.33)
-------
My toolbox and workbench:
Navicat for MySQL 16.0.13
FileZilla 3.57.1
Among others
-------
Development toolbox:
Adobe DreamWeaver 21.2
Adobe Photoshop 23.1.0
Adobe Illustrator 26.0.2
Adobe InDesign 17.0.1
Adobe XD
Visual Studio Code 1.63.2 (with some extensions enabled)
User avatar
Michalio
Moderator
Moderator
Posts: 209
Joined: Sun Jul 18, 2021 1:33 pm
Location: Poland

For make the code more clean I can suggest to add space before and after the dots, when you concating the strings.
But the code can be without space, with space, even with new line before or after, that code looks weird but it will works:

Code: Select all

 include __DIR__     .
 '
 /../Templates/'
 .     $templateFileName
 ;
Free coding lessons: https://php-forum.com/phpforum/viewtopic.php?t=29852
User avatar
NorseMan
php-forum Active User
php-forum Active User
Posts: 44
Joined: Mon Jul 04, 2022 5:25 pm
Location: Near Oslo (Norway)

Thanks Michalio. So it doesn't matter if it is with or without a space. That part of the problem was solved, and that is not where the error lies. Therefore, I can ignore __DIR__ . and move on debugging 😊🤓
________________
Leon (Norway)
________________

-------
(some of)My configuration is:
Laragon full 5.0 web server with PHP and MySQL installation
(Apache 2.4.47 / PHP 7.4.19 / MySQL 5.7.33)
-------
My toolbox and workbench:
Navicat for MySQL 16.0.13
FileZilla 3.57.1
Among others
-------
Development toolbox:
Adobe DreamWeaver 21.2
Adobe Photoshop 23.1.0
Adobe Illustrator 26.0.2
Adobe InDesign 17.0.1
Adobe XD
Visual Studio Code 1.63.2 (with some extensions enabled)
Post Reply