Jump to content

php Function parameter


danielki

Recommended Posts

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


Link to comment
https://forums.phpfreaks.com/topic/286934-php-function-parameter/
Share on other sites

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.

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 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.