How do I change string values in a variable?

example:
string = 'Hello'
print(string)
change string to 'Bye' <-- How do I do that?
print(string)

Recommended Answers

All 4 Replies

Try this.

<?php
$string = 'Hello<br>';
print($string);
$string = 'Bye<br>';
print($string);
?>

You can test it at http://phpfiddle.org/

string = 'Hello'
print(string)
string = 'Bye'
print(string)

@Grib. Are you sure about that? phpfiddle said:

FOUND 3 ERROR(S) AFFECTING 2 LINE(S)
--------------------------------------------------------------------------------
 2 | ERROR | Missing file doc comment
 2 | ERROR | Constants must be uppercase; expected STRING but found string
 4 | ERROR | Constants must be uppercase; expected STRING but found string
--------

`

commented: @grib is right. You can't run python on php fiddle +0

Well, the OP tagged the article with PYTHON so I kinda wonder why you posted php code.

commented: Mhissed that. Had PHP on the brain today. +7
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.