Consider:
$xml = "l";
$xml = "vv";
echo $xml;
This will echo vv. Why and how can I do multi-line strings for things like SimpleXML, etc.?
Consider:
$xml = "l";
$xml = "vv";
echo $xml;
This will echo vv. Why and how can I do multi-line strings for things like SimpleXML, etc.?
You need a Ajax call to pass the JS value into php variable
JS Code will be (your js file)
var jsString="hello";
$.ajax({
url: "ajax.php",
type: "post",
data: jsString
});
And in ajax.php (your php file) code will be
$phpString = $_POST['data']; // assign hello to phpString
A little digging in the Python source code shows that TestCase
registers a bunch of methods to test equality for different types.
self.addTypeEqualityFunc(dict, 'assertDictEqual')
self.addTypeEqualityFunc(list, 'assertListEqual')
self.addTypeEqualityFunc(tuple, 'assertTupleEqual')
self.addTypeEqualityFunc(set, 'assertSetEqual')
self.addTypeEqualityFunc(frozenset, 'assertSetEqual')
try:
self.addTypeEqualityFunc(unicode, 'assertMultiLineEqual')
except NameError:
# No unicode support in this build
pass
You can see that unicode
is registered to use assertMultiLineEqual()
, but str
is not registered for anything special. I have no idea why str
is left out, but so far I have been happy with either of the following two methods.
If an 8-bit string isn't registered to use assertMultiLineEqual()
by default, you can still call it directly.
def testString(self):
a = 'xaxnzzz'
b = 'xbxnzzz'
self.assertMultiLineEqual(a, b)
You can also register it yourself. Just add an extra line to your test case's setUp()
method. Do it once, and all your test methods will use the right method to test equality. If your project has a common base class for all test cases, that would be a great place to put it.
class TestAssertEqual(unittest.TestCase):
def setUp(self):
super(TestAssertEqual, self).setUp()
self.addTypeEqualityFunc(str, self.assertMultiLineEqual)
def testString(self):
a = 'xaxnzzz'
b = 'xbxnzzz'
self.assertEqual(a, b)
def testUnicode(self):
a = u'xaxnzzz'
b = u'xbxnzzz'
self.assertEqual(a, b)
Either of these methods will include highlighting when the string comparison fails.
Just use the new lines directly.
"email" = "Hello %@,
Check out %@.
Sincerely,
%@";
Well,
Works.
You can also use the following:
or
Edit based on comment:
You can concatenate strings using the
.=
operator.