Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info

    @Norris1z the trick is using the extract function:

    class View {
        private $templatePath;
        public function __construct($templatePath) {
            $this->templatePath = $templatePath;
        public function render($template, $vars = []) {
            require $this->templatePath . '/' . $template . '.php';
            return ob_get_clean();


    $view = new View(__DIR__ . '/templates');
    $vars = [
        'name' => 'Alex',
        'location' => 'Paris',
    echo $view->render('hello', $vars);


        Hello <?= $name ?>!<br>
        You are in <?= $location ?>.
    Norris Oduro
    @FlyLo11 thanks .
    is there a general reddit webdev room here on gitter

    $User_FName = $_POST['U_fname'];
    I want to know if the explanation below for the code above is right and if I can add to it

    //superglobal variable captures the value passed by form and store in local variable it is created when you use the post method in form to get the value that is entered in the form called u_fname.

    $SQL5="UPDATE orders SET orderTotal=".$total."
    WHERE orderNo=".$latestorderNo;// this updates the total value of orderTotal column in order table
    where the order No matches the order No of the order of the current user.
    @majedmahmood27 Do you have the code somewhere on github ?
    also, I'm trying to understand the problem, but i dont understand what your trying to do
    so maybe it's easier to see if i have the code
    @RNwebdk nope but how can I upload it I just need explanation of the code.It works
    Do you have a github account ?
    @RNwebdk yep
    okay, lets take it in private
    Roman Tsiupa
    hey guys)
    Hi guys
    need some help
    All info send to the template.html, but the info of telephone doesn't send why not what is my fault

    $time = date("Y-m-d H:i:s");//local varible that stores the date using the php function that format the date.
    is this rigth explanation
    // insert statment to put into orders the values id that is in the session ,time dynamically retrieved from local varibale and subtotal from local variable

    $userSQL =
    "insert into
    orders (userID, orderDateTime, orderTotal)
    values (".$_SESSION['c_userID'].",'".$time."','".$subTotal."')";//userID that is in the session

    if(mysql_errno($conn) == 0)
    //return the greatest order number... Meaning the largest number in the column and rename the column to max no
    $orderCheck = "SELECT max(orderNo) as 'maxno' FROM orders
    WHERE userID=".$_SESSION['c_userID'];
    $exeorderCheck = mysql_query($orderCheck) or die(mysql_error());
    $orderArray = mysql_fetch_array($exeorderCheck);
    $latestorderNo=$orderArray['maxno'];// stores max number of order for this particular user and store in local variable.
    echo "<p>Order has been placed successfuly";
    echo "<b><p>ORDER NO: ".$latestorderNo."</b>";// dynamically retrieve the value from the local variable latestorderNo.
    $SQL5="UPDATE orders SET orderTotal=".$total."
    WHERE orderNo=".$latestorderNo; this is update sql statement that updates the orderTotal database column using the total local variable wherethe orderNo matches the orderNo of the current user who has just placed an order
    $subTotal=$reququantity * $results3['prodPrice']; this is quantity retrieved from the for loop that times the array of records $result3 that references the prodPrice database column
    echo "<label for='First_name' >First Name: </label>"; what does label for do
    echo "<input type='text' name='U_fname' value=''><br>";//U_fname is the name of the textfield for First Name and is this right

    Open web market
    i would like some one to show me how to run this code (flif.exe -e input.png output.flif)
    shell_exec(“flif.exe -e input.png output.flif”);
    this code (flif.exe -e input.png output.flif) is giving me this error Parse error: syntax error, unexpected 'input' (T_STRING) in C:\
    I create multiple instances of a class in my code. Inside one of the class methods I have static $x = 0; $x++; When I call that method repeatedly, $x correctly increments. But when I call it from a different instance of the class it carries on from the same number, rather than starting from 0
    how can I get the static behaviour I want across multiple calls in the same instance, whilst starting from 0 for each separate instance?

    Essentially, how can I fix this?

    class MyClass() {
        // ....
        public function inc() {
            static $x = 0;
            return $x;
    $a = new MyClass;
    echo $a->inc();  //1, correct
    echo $a->inc();  //2, correct
    echo $a->inc();  //3, correct
    $b = new MyClass;
    echo $b->inc();  //4, incorrect, should be 1
    echo $b->inc();  //5, incorrect, should be 2
    echo $b->inc();  //6, incorrect, should be 3

    thank you!

    please ignore me, I realise how fuckbastardingly retarded I've been. That's what I get for trying to do 17 things at once after a month away from coding!
    Matthew J. Sahagian
    well this place is dead
    Richard Hagen
    @mattsah haha, it appears you are correct :/
    It use to be very active though :(
    Richard Hagen
    yup :/ It's to bad... maybe people still come around ;)
    btw, do you have any experience with docker / deployment routines?
    No sorry, i want to look into docker myself.
    Richard Hagen
    :) thanks tho
    @Richard87 join this slack channel, i'm sure you'll find someone that can help there
    Richard Hagen
    thanks :D
    Well it's been a lot of work, but I've finally converted my whole legacy codebase over to parameterised PDO queries. Easy for a lot of them (but there were a LOT of them), a bit more annoying for the queries that get built up in conditional logic. Feels good.
    now it's time to replace that with an ORM :P
    You shut your mot
    You shut your mouth :)
    you could try doctrine/dbal, it should be a drop-in replacement for PDO, and comes with some query building support
    I've always assumed that such a system would be too limiting - SQL is a very diverse language and while a coded query builder could account for 99% of my queries' needs I feel there would always be things I'd end up having to hand code?
    guys, i'm on a discord that has a little more activity then here, let me know if you would like a invite
    Ricardo Reis
    Anyone had issues with "readfile" and binary files?
    Actually, when using "readfile" to download a file on PHP, newline (13) characters get stripped
    Nicolaj Kirkgaard Nielsen
    Is there a way to receive a GET response from a server and echo it directly, including headers etc. I have an API endpoint i Wordpress that needs to request an image from another API with a token. The WP endpoint should just return the image exactly like the API response from the other API.