How to use single and double quotation marks in strings? In all programming languages, you must open and close your string with quotation marks, but you don't have to, if your interpreter doesn't consider the quotes (in the case of a string that does not contain spaces). Why the empty spaces? Because very often it means we are moving to another function.
How to add a quotation mark without truncating the string?
If your message is truncated or you receive an error message after adding quotes/apostrophe to a string, continue reading.
In PHP you can define your string with quotes and apostrophes.
A simple technique to avoid errors is to count the number of quotation marks or apostrophes, If it is odd, then it will certainly generate an error.
$mystring = "hello,";
In the case you need to add quotes:
$mystring = 'hello "John",';
(Change the character that delimits your string)
$mystring = "hello \"John\",";
(Use the backslash -> Escape character) This should be avoided:
$mystring = "He"llo,";
(Number of quotes is odd) PHP will stop at the second quotation mark and then wait for the end of instruction (the semicolon), but instead it will find the letter l, which is out of the string. Hence PHP will generate an error message.
Another frequent examples:
echo '<iframe src="[http://www.mysite.ty/mycode.html]" height="500px" width="96%" style="align: center;"></iframe>';
echo "<iframe src=\"[http://www.mysite.ty/mycode.html]\" height=\"500px\" width=\"96%\" style=\"align: center;\"></iframe>";
This is the same kind of situation, where we want PHP to add a string of characters containing quotes within a database.
In C language
The only solution is to make use of the escape character:
const char * mystring = Hello \"John\",";
Apostrophes can be used to declare ONLY ONE character:
char one_character = 'B';
VisualBasic 2.3 and ASCII
We will change a little bit. With VisualBasic:
Dim example as String example = "Je m' appelle : " & chr$(34) & "Zeurtchreinshrentizer" & chr$(34)
In this case we make use of the ASCII code (34) : The quote, which will be interpreted later.
Test it with:
Dim example as String example = "Je m' appelle : " & chr$(34) & "Zeurtchreinshrentizer" & chr$(34) MsgBox example
- Apostrophe in programming
- Quotation marks programming
- Quotation marks in programming
- Write a program to print a pattern like: 1 11 111 1111 11111 111111 [solved] > Forum - Programming
- Write a unix system program to read a file in reverse > Guide
- How to add apostrophe over e > Guide
- Count the visible clothes program > Forum - Programming
- Which key is used to delete programs or files permanently > Guide
- What are Accessors and Mutators C++
- My Documents + Environment Variables in VBA/VB6
- C++ open url: in default browser
- Keep application window on top of other apps with VB6
- Remove the underline from links in HTML, CSS
- How to draw a human face using code?
- VB6 RGB color: chart, codes
- How to calculate square root in C programming
- How to write and read CSV files in Python
- The best free online programming courses