webread and PHP: getting started

버전 1.0.0 (1.37 KB) 작성자: Kurt Fischle
short introductory example how to provide data for the MATLAB webread command from a web server using PHP
다운로드 수: 80
업데이트 2019/3/7

라이선스 보기

I recently needed to develop a MATLAB interface for a PHP based web application. I looked for a simple getting-started-guide, but did not find one; so I am sharing my first steps here in the hope they will save other developers a little time.

- First you need a web server; I am using XAMPP but this example should be quite generic.
- Put the example file get_lunch.php in the directory where your server looks for web pages, e.g. C:\xampp\htdocs
- Find out the required proxy settings, and check the MATLAB help on how to enter them. (This was actually what took the longest time for me.) If your organisation uses proxy exceptions, you might also want to check https://de.mathworks.com/matlabcentral/answers/284039-webread-not-behaving-per-docs
- Enter in MATLAB: webread('http://127.0.0.1/get_lunch.php','min_price',5,'max_price',7); struct2table(ans)
- The output should look like
ans =

Name veg Price
_________________ _____ _____

'American Salad' false 6.5
'Pizza Funghi' true 6
'Pizza Grandiosa' false 7

- Alternatively, you can include the request parameters in the URL; e.g. webread('http://127.0.0.1/get_lunch.php?min_price=5&max_price=7');
- to send a POST request instead of a GET request, you can use webread('http://127.0.0.1/get_lunch.php','min_price',5,'max_price',7,weboptions('RequestMethod','post'));
- if you are not running MATLAB on the same computer as your web server, you need to replace 127.0.0.1 by the IP address of your web server

인용 양식

Kurt Fischle (2026). webread and PHP: getting started (https://kr.mathworks.com/matlabcentral/fileexchange/70506-webread-and-php-getting-started), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2016b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Web Services에 대해 자세히 알아보기
태그 태그 추가
버전 게시됨 릴리스 정보
1.0.0