curl_setopt($ch, CURLOPT_NOBODY, true);
$phone = 79999999999;
$getPhone = function () use ($phone) {
return $phone;
};
echo $getPhone();
function getPhone($phone) {
return $phone;
}
echo getPhone($phone);
function getPhone() {
global $phone;
return $phone;
}
<input type="file" accept="image/*" @change="handleChange($event)" id="file-input">
<button v-on:click.prevent="handleSend">Отправить</button>
new Vue({
el: '#app',
data: {
name: 'John Doe',
keywords: 'key',
form: new FormData()
},
methods: {
handleSend: function () {
// upload image
axios.put(
'/upload',
this.form, {
header: {
'Content-Type': 'image/png'
}
}
).then(response => {
console.log('image upload response > ', response);
});
// send form
axios.post('/api/crud', {
name: this.name,
keywords: this.keywords,
title: this.name
}).then(response => {
console.log(response);
}).catch(error => {
console.log(error.response);
});
},
handleChange: function (event) {
this.form.append('name', 'my-picture');
this.form.append('file', event.target.files[0]);
},
}
});
app.post('/comment',function (req,res,next) {
console.log(req.body.email);
res.send('Hello World!');
});
const router = new VueRouter({
routes: [
{ path: '/post/:slug', component: User }
]
})
watch: {
'$route'(to) {
axios.get(`project.com/posts/${to.params.slug}`).then();
}
}
<form name="person">
<input name="name" value="Иван">
<input name="surname" value="Иванов">
</form>
var object = {};
var formData = new FormData(document.forms.person);
formData.forEach(function(value, key){
object[key] = value;
});
var json = JSON.stringify(object);
var xhr = new XMLHttpRequest();
xhr.open("POST", '/submit', true)
xhr.setRequestHeader('Content-type', 'application/json; charset=utf-8');
// Отсылаем объект в формате JSON и с Content-Type application/json
xhr.send(json);