Jump to content

papaface

Members
  • Posts

    1,437
  • Joined

  • Last visited

    Never

Posts posted by papaface

  1. I'd do:

    <?php
    $i = 0;
    while ($i < 4)
    {
    echo rand(0,100) . "<br />";
    $i++;
    }
    ?>
    

    or:

    $rand = array(rand(0,100),rand(0,100),rand(0,100),rand(0,100));
    foreach ($rand as $val)
    {
    echo $val . "<br />";
    }

    or:

    $rand1 = rand(0,100);
    $rand2 = rand(0,100);
    $rand3 = rand(0,100);
    $rand4 = rand(0,100);
    echo $rand1 ." ". $rand2 ." ". $rand3 ." ". $rand4;

     

  2. Restart the server!? How come cPanel is able to acomplish this without having to restart the server (or am I deeply mistakened)?

    I just want to put addon domains for different users automatically via PHP as they submit them and change their nameservers.

     

    I'm guessing I would have to create a desktop application and then use exec() to call it to do the job? I'm not looking for any quick tricks in PHP to do this as I know it will mean work and I am willing to spend time into researching and doing this properly along with the rest of the project I am doing.

     

    :)

    I'm sure cpanel does restart apache when a new domain is added.

  3. Yeah, you can do that, but that just means the index page will get a lot of data passed to it. By the way, that method isn't the best solution. It'll make the index page a b*tch to code.

    Not necessarily if you code it correctly.

    I would do something like:

    Index.php:

    <?php
    if	(strlen($_GET['p']) > 0)
    {
    switch($_GET['p'])
    	{
    	case "register":
    	include("register.php");
    	break;
    
    	case "login":
    	include ("login.php");
    	break;
    
    	default:
    	include ("indexpage.php");	
    	}
    }	
    else
    {
    include ("indexpage.php");		
    }
    ?>

    Pretty simple in my opinion. Just code the pages separately but include them as one page using switch and NOT if statements.

     

  4. <?php
    function test() {
    
    // get the array name
    $array_name = 'foo';
    
    // initiate all elements to be zeros
    for ( $i=1;$i<=10;$i++ ) {
      $$array_name[$i] = '';
    }
    
    // assign each element of array a value
    for ( $i=1;$i<=10;$i++ ) {
      $$array_name[$i] = 'bar' . $i;
    }
    
    return $array_name;
    }
    $test = test();
    print_r($test);
    
    ?>

    Do you mean like that?

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