Jump to content

space before perode or not.


LeonLatex

Recommended Posts

Dump the value of __DIR__ so you can see what it ends with. You can assume that's mostly always going to be the case. Then consider whether there are possible exceptions to that. Then realize that having doubled-up slashes doesn't cause any problems.

Link to comment
Share on other sites

5 hours ago, LeonLatex said:

include __DIR__ . '/../Templates/'

Is it correct with a space before and after the period or not?

The period is the String concatenation operator and PHP isn't fussy about having whitespace around its operators so it should work with either. 
Personally, I like the spaces.  Other people I work with detest them. 

Go with whichever fits your Coding Standards.  😉

Personally, I would also question the use of ".." in your paths. 
To me, it suggests that you should be "anchoring" your paths "further up" the directory tree.  As it is, you're making assumptions about what's "outside" the directory your script lives in and, if you refactored and moved things around, you could end up breaking things.  (That said, this might just be a hang-over from my spending too many years writing ASP running under IIS). 

Regards, 
   Phill  W.

 

Link to comment
Share on other sites

Ok, I like to have spaces too. It makes it more....... readable if you understand what I mean. I was not sure if it was this making the problem for me. If it depends if there is a space or not. Now I know for sure it is not here the problem is. I haven't looked into it today, so I don't know where the error is. But hope I find the error today. Thanks for helping me out and making it clear. I will look in ti your suggestion and see if I find out about this too. I bet you are into security reasons....🤔

Stressful day. 🤪This was awfully bad English. Anyway, I hope you understand.

Edited by LeonLatex
Link to comment
Share on other sites

11 hours ago, Barand said:

Me too. I think a small but important operator like that gets lost without the whitespace.

As I already said, it makes it easier and more readable with white spaces. I feel it that way. So, when possible, I put in a white space where I can.
What about this block:

<?php
function loadTemplate($templateFileName, $variables = []) {
    extract($variables);

    ob_start();
    include __DIR__.'/../templates/' .$templateFileName;
    return ob_get_clean();
}

 

Can I have a space between the period/dot and $ here too?

.$templateFileName;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.