user23328: I try to make a variable that can be modified from the server, using and ESP8266.
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

const char* ssid = "********";
const char* password = "*********";

ESP8266WebServer server(80);

const int led = 13;

void handleRoot() {
    digitalWrite(led, 1);
    server.send(200, "text/plain", "hello from esp8266!");
    digitalWrite(led, 0);
}

void handleNotFound() {
    digitalWrite(led, 1);
    String message = "File Not Found\n\n";
    message += "URI: ";
    message += server.uri();
    message += "\nMethod: ";
    message += (server.method() == HTTP_GET)?"GET":"POST";
    message += "\nArguments: ";
    message += server.args();
    message += "\n";

    for (uint8_t i=0; i<server.args(); i++){
        message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
    }

    server.send(404, "text/plain", message);
        digitalWrite(led, 0);
    }
}

void setup(void) {
    pinMode(led, OUTPUT);
    digitalWrite(led, 0);
    Serial.begin(115200);
    WiFi.begin(ssid, password);
    Serial.println("");

    // Wait for connection
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }

    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());

    if (MDNS.begin("esp8266")) {
        Serial.println("MDNS responder started");
    }

    String content = "Basic";
    content += "<html><body><form action='action_page.php' method='POST'><br>";
    content += "User:<input type='text' name='USERNAME' placeholder='user name'>       <br>";
    content += "<input type='submit' name='SUBMIT' value='Submit'></form><br>";

    server.on("/led", [](){
        server.send(200, "text/html", content);
        Serial.println(USERNAME);
    }

    server.on("/", handleRoot);

    server.on("/inline", [](){
        server.send(200, "text/plain", "this works as well");
    });

    server.onNotFound(handleNotFound);
    server.begin();
    Serial.println("HTTP server started");
}

void loop(void){
    server.handleClient();
}

When I compile it, it says 

'content' is not captured

I thought it may be from the input, and I tried to name it "Basic" for the start, but it still failed.

user10794: Let's look at a simpler example:
void setup ()
{
  String content = "Basic";

  attachInterrupt (digitalPinToInterrupt (2),
                   []()
  {
    Serial.println(content);
  }, 

  FALLING );

}  // end of setup

void loop () { }

This gives the error:
/tmp/arduino_modified_sketch_182173/sketch_jan25a.ino: In lambda function:
sketch_jan25a:8: error: 'content' is not captured
     Serial.println(content);

Why? Because you are using a local variable content in a lambda function which runs at global scope. That is, content is not available to it, because it is inside setup.
To capture it, you can put it in the capture list:
  attachInterrupt (digitalPinToInterrupt (2),
                   [content]()  // capture content

However I found that my example doesn't compile even then.

I think the reason for that can be found here: Lambda Functions in C++11 - the Definitive Guide

How are Lambda Closures Implemented?
So how does the magic of variable capture really work? It turns out that the way lambdas are implemented is by creating a small class; this class overloads the operator(), so that it acts just like a function. A lambda function is an instance of this class; when the class is constructed, any variables in the surrounding enviroment are passed into the constructor of the lambda function class and saved as member variables. 

You can't pass an instance of a class to attachInterrupt because there is a hidden *this variable that needs to be passed to class instances, and ISRs don't do that.
Now your example isn't an ISR, but probably the same remarks apply.

I don't think there is an enormous amount of point of using lambda functions here. If you must, move content inside the lambda, since that is where you are using it.
Or failing that, make it global scope.

The closest I could get to something that compiled was:
void setup ()
{
  const int content = 42;

  attachInterrupt (digitalPinToInterrupt (2),
                   [=]()
  {
    Serial.println(content);
  },

  FALLING );

}  // end of setup

void loop () { }

Honestly though, I think using lambda functions here just makes your code obscure.

23328: <p>I try to make a variable that can be modified from the server, using and ESP8266.</p>

<pre><code>#include &lt;ESP8266WiFi.h&gt;
#include &lt;WiFiClient.h&gt;
#include &lt;ESP8266WebServer.h&gt;
#include &lt;ESP8266mDNS.h&gt;

const char* ssid = "********";
const char* password = "*********";

ESP8266WebServer server(80);

const int led = 13;

void handleRoot() {
    digitalWrite(led, 1);
    server.send(200, "text/plain", "hello from esp8266!");
    digitalWrite(led, 0);
}

void handleNotFound() {
    digitalWrite(led, 1);
    String message = "File Not Found\n\n";
    message += "URI: ";
    message += server.uri();
    message += "\nMethod: ";
    message += (server.method() == HTTP_GET)?"GET":"POST";
    message += "\nArguments: ";
    message += server.args();
    message += "\n";

    for (uint8_t i=0; i&lt;server.args(); i++){
        message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
    }

    server.send(404, "text/plain", message);
        digitalWrite(led, 0);
    }
}

void setup(void) {
    pinMode(led, OUTPUT);
    digitalWrite(led, 0);
    Serial.begin(115200);
    WiFi.begin(ssid, password);
    Serial.println("");

    // Wait for connection
    while (WiFi.status() != WL_CONNECTED) {
        delay(500);
        Serial.print(".");
    }

    Serial.println("");
    Serial.print("Connected to ");
    Serial.println(ssid);
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());

    if (MDNS.begin("esp8266")) {
        Serial.println("MDNS responder started");
    }

    String content = "Basic";
    content += "&lt;html&gt;&lt;body&gt;&lt;form action='action_page.php' method='POST'&gt;&lt;br&gt;";
    content += "User:&lt;input type='text' name='USERNAME' placeholder='user name'&gt;       &lt;br&gt;";
    content += "&lt;input type='submit' name='SUBMIT' value='Submit'&gt;&lt;/form&gt;&lt;br&gt;";

    server.on("/led", [](){
        server.send(200, "text/html", content);
        Serial.println(USERNAME);
    }

    server.on("/", handleRoot);

    server.on("/inline", [](){
        server.send(200, "text/plain", "this works as well");
    });

    server.onNotFound(handleNotFound);
    server.begin();
    Serial.println("HTTP server started");
}

void loop(void){
    server.handleClient();
}
</code></pre>

<p>When I compile it, it says </p>

<blockquote>
  <p>'content' is not captured</p>
</blockquote>

<p>I thought it may be from the input, and I tried to name it "Basic" for the start, but it still failed.</p>
 10794: <p>Let's look at a simpler example:</p>

<pre><code>void setup ()
{
  String content = "Basic";

  attachInterrupt (digitalPinToInterrupt (2),
                   []()
  {
    Serial.println(content);
  }, 

  FALLING );

}  // end of setup

void loop () { }
</code></pre>

<p>This gives the error:</p>

<pre><code>/tmp/arduino_modified_sketch_182173/sketch_jan25a.ino: In lambda function:
sketch_jan25a:8: error: 'content' is not captured
     Serial.println(content);
</code></pre>

<p>Why? Because you are using a local variable <code>content</code> in a lambda function which runs at global scope. That is, <code>content</code> is not available to it, because it is inside <code>setup</code>.</p>

<p>To capture it, you can put it in the capture list:</p>

<pre><code>  attachInterrupt (digitalPinToInterrupt (2),
                   [content]()  // capture content
</code></pre>

<p>However I found that my example doesn't compile even then.</p>

<hr>

<p>I think the reason for that can be found here: <a href="http://www.cprogramming.com/c++11/c++11-lambda-closures.html" rel="nofollow noreferrer">Lambda Functions in C++11 - the Definitive Guide</a></p>

<blockquote>
  <p><strong>How are Lambda Closures Implemented?</strong></p>
  
  <p>So how does the magic of variable capture really work? It turns out that the way lambdas are implemented is by creating a small class; this class overloads the operator(), so that it acts just like a function. A lambda function is an instance of this class; when the class is constructed, any variables in the surrounding enviroment are passed into the constructor of the lambda function class and saved as member variables. </p>
</blockquote>

<p>You can't pass an instance of a class to <code>attachInterrupt</code> because there is a hidden <code>*this</code> variable that needs to be passed to class instances, and ISRs don't do that.</p>

<p>Now your example isn't an ISR, but probably the same remarks apply.</p>

<hr>

<p>I don't think there is an enormous amount of point of using lambda functions here. If you must, move <code>content</code> inside the lambda, since that is where you are using it.</p>

<p>Or failing that, make it global scope.</p>

<hr>

<p>The closest I could get to something that compiled was:</p>

<pre><code>void setup ()
{
  const int content = 42;

  attachInterrupt (digitalPinToInterrupt (2),
                   [=]()
  {
    Serial.println(content);
  },

  FALLING );

}  // end of setup

void loop () { }
</code></pre>

<p>Honestly though, I think using lambda functions here just makes your code obscure.</p>
