Eg instead of path\to\file.php, you would do 'path'. So, theoretically, your PHP code can just use DIRECTORY_SEPARATOR in paths, and you’ll be ok. (I suppose a Windows 10 machine using the Linux subsystem will emulate Linux and so use /). There is a constant called DIRECTORY_SEPARATOR, which is / on Unix-style operating systems, and it’s \ on Windows machines. Let me tell what the options are, then their problems. This isn’t a new problem, by any means, and the programming language PHP has given us two different attempts to fix it, but each has problems. So, on Windows machines, the path to a file will look something like this: path\to\file.php, whereas on Unix-style operating systems (even if they’re a virtual machine, like VVV), the paths instead look like path/to/file.php. Plus, if you’re writing code that works with WordPress, there are a few more considerations. But the problem gets worse if the code will be distributed and could be run anywhere. This forward-or-backslashes problem occurs a little when you’re writing code that will only ever run on one machine. This meant that some unit test code expected to find forward slashes, and when it found backslashes, reported an error. It’s been quite a while since any of us at Event Espresso have ran our code on a Windows machine directly, so there were a few problems, chiefly that Windows uses backslashes, \, to separate folders, whereas Unix-style operating systems use forward slashes, /. BackstoryĪt work, I’ve recently had some trouble getting my linux virtual machine VVV to work and so have been trying out a different system that runs my development websites directly on my Windows operating system, Laragon. PHP has two built-in solutions, but both have problems, especially if you’re working with WordPress. But if you’d like to be extra sure your writing is error free, we’re always here to help.When writing out filepaths and URLs, should you use forward slashes / or backslashes \? Windows expects one, whereas Unix-style operating systems (Linux and Mac OSs, primarily) expect another. Thus, usually, the correct slash will be the forward slash. Since the backslash is not a punctuation mark, you will rarely need it in writing. It’s also used to write dates, fractions, abbreviations, and URLs. The forward slash (/) can be used in place of “or” in less formal writing.The backslash (\) is mostly used in computing and isn’t a punctuation mark.Summary: The Backslash and Forward SlashĪlthough these symbols look similar, forward slashes and backslashes have different uses. Usually, though, an en dash is the standard punctuation for indicating a relationship like this. There are some cases when a slash is the correct symbol use in formal writing (e.g., when one of the connected things is a hyphenated compound). Soviet –US relations were tense throughout the 1960s. In formal writing, however, you should use an en dash to indicate connections instead: This use of a slash is okay in less formal writing. Soviet /US relations were tense throughout the 1960s. You may also see a forward slash used to indicate a relationship. Certain abbreviations (e.g., c/o = care of, n/a = not applicable).Separating lines of poetry on a single line (e.g., I wandered lonely as a cloud/That floats on high o’er vales and hills).Indicating “per” in a measurement (e.g., 50 lbs/day = fifty pounds per day).Fractions or indicating division (e.g., 5/8 = five eighths).Thank you for subscribing to our newsletter! Other common uses of the forward slash include: However, you should avoid doing this too often in formal writing, where “or” is a better choice. The slash here shows that either word could apply. Its most common use is to mean “or” when presenting two alternatives:Įach speaker will give a presentation on a topic of his /her choice. While the backslash is a specialist, the forward slash is a Jack-of-all-trades. However, you shouldn’t typically need to use a backslash in your writing. You’ll also see it if you look up a file directory in Windows (although not on Apple computers, which use a different system). The true home of the backslash is computing, where it is used in various programming languages. But it doesn’t have a function in punctuation, and you will not find it in most writing. It is a typographic mark (i.e., something you can type). The slash that isn’t technically a “punctuation” mark we mentioned is the backslash ( \ ). Here, we look at what backslashes and forward slashes represent and how they should be used if you want to avoid errors when using them in your writing. But wait! Did you know that only one of these is technically a punctuation mark? If not, you might find this guide useful! Today, we’re looking at some oft-overlooked punctuation marks: the backslash and the forward slash. Punctuation Tips: The Backslash and Forward Slash
0 Comments
Leave a Reply. |