danielki Posted March 13, 2014 Share Posted March 13, 2014 Hello, I am new to php and I am trying to do the following task. I tried to look on the internet for a php function which can help me solve the task but I couldn't come up with any valuable one. Can any one suggest any function or give me a hint on how to solve the following? thank you in advance. Your task is to complete the below program so that it prints as shown in the example. There's only one missing function that you need to write. Just write that missing function in the text box. Incomplete program: <?php // Your code here $charstring = "first\n"; newvalue($charstring); echo "String in the end: $charstring\n"; ?> Example output String in the start: first String in the end: New string Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted March 13, 2014 Share Posted March 13, 2014 (edited) This tasks is for you to write the missing function called newvalue (not for someone else on the internet to do it for you). The job of the function is to change the value of $charstring from "First" to "New String". The solution is a simple one but requires the use of globals which is not recommended. It will be better if the function returned the new value instead. Edited March 13, 2014 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
gristoi Posted March 13, 2014 Share Posted March 13, 2014 I agree with Ch0cu3r. You need to write this out, and then ask for help. Not just get someone else to do the work. Whats the point if you don't learn anything? And if the person / site giving you the task to do is asking you to use globals then i would seriously look elsewhere as this is a severly outdated methodolgy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.