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
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.

Edited by Ch0cu3r
Link to comment
Share on other sites

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 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.