반응형
250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- node
- chart.js
- docker
- AWS CI/CD 구축하기
- Spring
- codedeploy error
- codedeploy
- bootstrap
- java bigdecimal
- JavaScript
- redis
- aws
- Jenkins
- IntelliJ
- codebuild
- 도커
- or some instances in your deployment group are experiencing problems.
- VPN
- Kafka
- COALESCE
- chartjs
- PostgreSQL
- codepipeline
- SQL
- Airflow
- Flux
- kubeflow
- Spring Error
- aws cicd
- Python
Archives
- Today
- Total
Small Asteroid Blog
[php] PHP Warning: Illegal string offset ' ' in 본문
728x90
다음과 같은 에러는 string 형태의 변수 뒤에 오프셋 형태로 '인자'값을 붙여서 나는 에러로
주로 string 문자열 변수를 array 배열로 착각하여 변수 뒤에 오프셋 값을 넣을 때 나타난다.
$list = "번호입니다.";
// error
$result = array();
foreach ($list as $row) {
$result[] = array(
'no' => $row['no']
);
}
다음과 같은 경우에 먼저 $aResult 를 배열로 선언해주고
$result = array();
배열인지 아닌지 확인해주는 함수를 넣어서 해결해도 좋다.
if(is_array($result)){
$result = array();
foreach ($list as $row) {
$result[] = array(
'no' => $row['no']
);
}
}
728x90
반응형
'백엔드' 카테고리의 다른 글
[php] result_array() and row_array() (0) | 2022.07.12 |
---|---|
[php] What does this mean in PHP: -> or => (0) | 2022.07.08 |
[php] Message: Cannot modify header information - headers already sent by (output started at ) 에러 해결 (2) | 2022.07.06 |
[window] WSL2 Ubuntu 구동 시 Error: 0x800701bc WSL 2 (0) | 2022.04.28 |
메시지 브로커 / 이벤트 브로커 (0) | 2022.04.26 |