Giter Site home page Giter Site logo

How ı can change variable about ngx-php HOT 12 OPEN

rryqszq4 avatar rryqszq4 commented on May 18, 2024
How ı can change variable

from ngx-php.

Comments (12)

fatalafitili avatar fatalafitili commented on May 18, 2024 1

@fatalafitili

Change access_by_php to rewrite_by_php, I found it is ok.

...

set $sel 0;
location = / {
    rewrite_by_php '
        $x = 1; 
        ngx_var::set("sel", $x);
    '; 
    return 200 $sel;
}

...

Oh I so happy, this worked thanks dude, i love u <3 @rryqszq4

from ngx-php.

rryqszq4 avatar rryqszq4 commented on May 18, 2024

@fatalafitili
I tested that the access_by_php directive was not executed.Need to research in depth.

from ngx-php.

fatalafitili avatar fatalafitili commented on May 18, 2024

@rryqszq4 I wait u

from ngx-php.

rryqszq4 avatar rryqszq4 commented on May 18, 2024

@fatalafitili
The 'return' directive is in the 'rewrite' phase, earlier than the 'access' phase.

Try the following example:

...

set $sel 0;
location = / {
    access_by_php '
        $x = 1; 
        ngx_var::set("sel", $x);
    '; 
    content_by_php '
        echo ngx_var::get("sel");
    ';
}

...

from ngx-php.

fatalafitili avatar fatalafitili commented on May 18, 2024

@fatalafitili
The 'return' directive is in the 'rewrite' phase, earlier than the 'access' phase.

Try the following example:

...

set $sel 0;
location = / {
    access_by_php '
        $x = 1; 
        ngx_var::set("sel", $x);
    '; 
    content_by_php '
        echo ngx_var::get("sel");
    ';
}

...

I know it works but I want to change a variable in nginx.

for example

`set $sel 0;
location = / {
    access_by_php '
        $x = 1; 
        ngx_var::set("sel", $x);
    '; 
    content_by_php '
        echo ngx_var::get("sel");
    ';
    if ($sel = 1) {
     #I want to make transactions here
    }

}`

@rryqszq4 Isn't it possible ?

from ngx-php.

rryqszq4 avatar rryqszq4 commented on May 18, 2024

@fatalafitili
For example about what transactions?

from ngx-php.

fatalafitili avatar fatalafitili commented on May 18, 2024

@rryqszq4
My only goal is to change the value of a nginx variable with php,
I can use that variable in all fields, usually if parameter

from ngx-php.

rryqszq4 avatar rryqszq4 commented on May 18, 2024

@fatalafitili
I think the ‘rewrite_by_php’ directive should be used, but there are some bugs.
=.=

from ngx-php.

fatalafitili avatar fatalafitili commented on May 18, 2024

@rryqszq4

Okay, buddy, I'm gonna do it for now, but I'm waiting for an update. :)

from ngx-php.

rryqszq4 avatar rryqszq4 commented on May 18, 2024

@fatalafitili

Change access_by_php to rewrite_by_php, I found it is ok.

...

set $sel 0;
location = / {
    rewrite_by_php '
        $x = 1; 
        ngx_var::set("sel", $x);
    '; 
    return 200 $sel;
}

...

from ngx-php.

fatalafitili avatar fatalafitili commented on May 18, 2024

Hello dude i again here :) my problem is not fully solved, look this;

image

it's not complete, but it's logic

i did use this but this is not worked, 404 does not;

i need this:

Example:

(php counts how many times each user enters)

php variable if 100, nginx variable 1 do

if nginx variable 1, go return 404 else go location /

i need to do this, can u help again me ? @rryqszq4

from ngx-php.

fatalafitili avatar fatalafitili commented on May 18, 2024

That's the right logic, but it doesn't work;

image

from ngx-php.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.