Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7624627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:00:51+00:00 2026-05-31T05:00:51+00:00

I remember reading in a JavaScript tutorial that it’s generally best to avoid using

  • 0

I remember reading in a JavaScript tutorial that it’s generally best to avoid using single line comments incase someone in the future decided they wanted to compress the file and remove all the white space.

Does the same ring true in PHP? Should I use multi-line comments even when I’m only going to be occuping one line, e.g.

echo $var; /*This code echoes a variable*/ 

or is it fine to use single line comments in such situations?

And are PHP files ever compressed by removing white space, or is that a little extreme?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:00:52+00:00Added an answer on May 31, 2026 at 5:00 am

    is it fine to use single line comments in such situations?

    Short answer: Yes.
    If someone compresses whitespace and breaks your code, it’s their fault for not doing it right.

    Any PHP or JS source compressor worth using should be smart enough to know what to remove and what not to touch, and all comments will generally be stripped anyways so it’s not a related issue. You shouldn’t be coding around such things.

    The only practical reason I can think of to avoid single line comments is that sometimes there are issues with line endings when you go to/from a Windows and *NIX server. If you’re using Windows style newlines and your file retains them on a *NIX server, your single line comments will end up commenting out your actual code, messing everything up. /* Comments like this */ won’t affect anything. Example:

    $var = 'Hello'; // Say hello
    echo $var;
    

    Upload to UNIX server with Windows style \r\n newlines:

    $var = 'Hello'; // Say helloecho $var;
    

    You could end up executing some unintended, dangerous code if you run it.

    However: If that happens, it’s a symptom of another problem that should be resolved anyways. I’ve had this happen to me a few times, so I know it’s possible. Many FTP clients will convert newlines anyways.

    So in reality: Yes, it’s fine to use single line comments. Comments are for the author, not the compiler or parser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I remember reading in Douglas Crockford's Javascript the Good Parts book that there is
I remember reading somewhere that you can provide your own icons without having them
I remember reading at one point that indexing a field with low cardinality (a
I remember reading once that the order of the members of an evaluation is
I remember reading a blog post about a group that had taken a branch
I remember reading that static variables declared inside methods is not thread-safe. (See What
I remember reading an article that an average programmer spends 90% of the working
I think I remember reading that that has to do with telling the browser
I remember reading somewhere that SQL Azure is going to terminate long-running queries. Is
I remember reading in passing that some of the new language features in C#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.